Vitral 0.2.18
Menu

Menu

A list of commands and links, inline or as a popup, with groups and separators.

Import

main.ts
import { Menu } from '@vitral/vue';

Inline, with groups

Last command: —
<script setup lang="ts">import { Menu, type MenuItem } from '@vitral/vue';import { ref } from 'vue'; const last = ref('—');const run = ({ item }: { item: MenuItem }) => (last.value = item.label ?? ''); const grouped: MenuItem[] = [    {        label: 'Documents',        items: [            { label: 'New', icon: 'plus', command: run },            { label: 'Search', icon: 'search', command: run }        ]    },    {        label: 'Profile',        items: [            { label: 'Settings', icon: 'sliders', command: run },            { label: 'Notifications', icon: 'bell', command: run, disabled: true },            { label: 'Help', icon: 'externalLink', url: '#' }        ]    }];</script> <template>    <Menu :model="grouped" aria-label="Account" />    <small style="color: var(--vt-text-muted-color)">Last command: {{ last }}</small></template>

API

Read from packages/vue/src/components/Menu/types.ts, so it says what the component actually accepts.

Props

NameTypeDescription
arrow booleanA pointer from the panel to what opened it, on whichever side the panel ends up. The plugin's `overlayArrow` otherwise, which is off.
model MenuItem[]—
popup booleanA popup menu, opened by `toggle(event)` / `show(event)` and anchored to the event's element.
appendTo stringWhere a popup renders: `'body'` (the default), `'self'` to stay in place, or a selector.
placement OverlayPlacement—
ariaLabel stringNames the menu. A popup without one is named by the element that opened it.
ariaLabelledby string—

Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.

Emits

EventPayloadDescription
show ——
hide ——

Slots

NameSlot propsDescription
start —Content before the items.
end —Content after the items.
item (props: { item: MenuItem; label: string | undefined; focused: boolean; disabled: boolean })An item's content: its icon and label. The menuitem element around it, with its role and keyboard, stays.
submenulabel (props: { item: MenuItem })A group's heading.