WlMenu
Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.
Settings
Accessible menu name.
Popup menu animation; defaults to WlConfig.motion (true).
Props items, popup, ariaLabelledby, pt, placement, align, models, handlers and slots can be edited in the SFC. See their descriptions in API.
Popup menu with a trigger button is shown in the example below.
Example
- Material
Choose an action · View: list · false
Explore the live example and copy its Vue SFC into your application. Settings on the left can be combined.
Code for your application
Vue SFC · current settings
<script setup lang="ts">
import { WlMenu, type WlMenuItem } from "legato-ui";
import { computed, ref } from "vue";
const selection = ref("Choose an action");
const compact = ref(false);
const view = ref("list");
const items = computed<WlMenuItem[]>(() => [
{ header: "Material" },
{ key: "edit", label: "Edit", icon: "edit", command: () => { selection.value = "Editing"; } },
{ key: "view", label: "View", items: [
{ key: "list", label: "List", type: "radio", group: "View", checked: view.value === "list", onCheckedChange: () => { view.value = "list"; } },
{ key: "grid", label: "Grid", type: "radio", group: "View", checked: view.value === "grid", onCheckedChange: () => { view.value = "grid"; } },
{ separator: true },
{ key: "compact", label: "Compact header", type: "checkbox", checked: compact.value, onCheckedChange: (checked) => { compact.value = checked; } }
] },
{ key: "lock", label: "Unavailable", disabled: true },
{ separator: true },
{ key: "delete", label: "Delete", icon: "trash", danger: true, command: () => { selection.value = "Deletion"; } }
]);
</script>
<template>
<div class="wl-stack" data-space="md">
<WlMenu :items="items" aria-label="Material actions" />
<p role="status" class="wl-text-small">{{ selection }} · {{ "View" }}: {{ view }} · {{ compact }}</p>
</div>
</template>Static and popup menus
Heading, separator, icons, shortcut label, disabled and danger; commands produce a local result.
- Material
No command selected yet.
↑/↓, Home and End move focus. Escape closes the popup. Shortcut displays the key combination; the application adds its handler.
Vue SFC · additional example
<script setup lang="ts">
import { WlButton, WlMenu, type WlMenuExpose, type WlMenuItem } from "legato-ui";
import { ref } from "vue";
const popup = ref<WlMenuExpose | null>(null);
const message = ref("No command selected yet.");
const items: WlMenuItem[] = [
{ header: "Material" },
{ key: "edit", label: "Edit", icon: "edit", shortcut: "Ctrl+E", command: () => message.value = "Editing opened." },
{ key: "copy", label: "Copy link", icon: "copy", command: () => message.value = "Local copy example." },
{ key: "export", label: "Export", icon: "download", disabled: true },
{ separator: true },
{ key: "remove", label: "Delete", icon: "trash", danger: true, command: () => message.value = "Deletion selected; the application adds confirmation." }
];
</script>
<template>
<div class="wl-stack" data-space="lg">
<div><WlMenu :items="items" aria-label="Static material commands" /></div>
<div><WlButton @click="popup?.toggle($event)">{{ "Open popup menu" }}</WlButton><WlMenu
ref="popup"
popup
:items="items"
aria-label="Material popup commands"
/></div>
<p class="wl-text-small" role="status">{{ message }}</p>
<p class="wl-text-small wl-text-muted">{{ "↑/↓, Home and End move focus. Escape closes the popup. Shortcut displays the key combination; the application adds its handler." }}</p>
</div>
</template>Props
Types, accepted values and literal defaults come from the public manifest. Inherited settings name their source; “Not set” means no default is declared.
| Prop | Type / values | Default | Purpose |
|---|---|---|---|
items | readonly (Item & WlMenuItem< | [] | WlMenuItem[]: { key?, label?, icon?, shortcut?, danger?, disabled?, separator?, header?, command? }. |
popup | boolean | false | Popup menu; opened through toggle/show. |
ariaLabel | string | Not set | Accessible menu name. |
ariaLabelledby | string | Not set | ID of the element labelling the menu. |
motion | boolean | Inherits WlConfig.motion | Popup menu animation; defaults to WlConfig.motion (true). |
pt | WlPt< | Not set | Attributes of internal Legato UI elements. |
placement | WlPopoverPlacement | "auto" | Preferred overlay side relative to its anchor. |
align | WlPopoverAlign | "start" | Alignment of the overlay along its anchor. |
Events
| Event | Payload | When emitted |
|---|---|---|
open | [] | Popup menu opened. |
close | [] | Popup menu closed. |
check | [event: WlMenuCheckEvent< | Emitted when a menu checkbox or radio item changes its checked state. |
Slots
| Slot | Type / values | Content |
|---|---|---|
trigger | trigger?(props: WlMenuTriggerSlotProps): unknown; | Custom trigger; bind its supplied attributes and use the provided open/close actions. |
Pass-through: pt
Sections WlMenu are listed below. Attributes merge in this order: createWlPt() WlConfig.ptpt instance. Class and style merge; the last supplied value takes priority for other attributes.
| Section | DOM | Purpose |
|---|---|---|
root | div.wl-menu | The root section in WlConfig.pt.menu configuration. |
list | ul.wl-menu__list | The list section in WlConfig.pt.menu configuration. |
item | li.wl-menu__item | The item section in WlConfig.pt.menu configuration. |
submenuLabel | div.wl-menu__head | The submenuLabel section in WlConfig.pt.menu configuration. |
separator | div.wl-menu__sep | The separator section in WlConfig.pt.menu configuration. |
itemContent | div.wl-menu__item-content | The itemContent section in WlConfig.pt.menu configuration. |
itemLink | button / a.wl-menu__link | The itemLink section in WlConfig.pt.menu configuration. |
checkIcon | span.wl-menu__check | Decorative checkbox/radio state icon; checked state stays on the menu item. |
submenuIcon | span.wl-menu__submenu-icon | Decorative indicator of a nested menu. |
Sections refer to the component DOM. Dotted names identify a configuration group and its section; composite parts use their own pt groups. Global and local attributes merge, with class and style added together.
Keyboard and accessibility
- Give static and popup menus different ariaLabel values; items use menu/menuitem roles.
- ArrowDown/ArrowUp, Home and End move focus and skip disabled items. Escape closes the popup and restores focus to the trigger.
- Shortcut is only a label. The application defines commands, keyboard shortcuts and whether dangerous actions need confirmation.
Keyboard and application responsibilities
| Key | Action |
|---|---|
| ↑ / ↓, Home / End | Move between enabled menu items. |
| → / ← | Open a submenu or return to its parent. |
| Enter / Space | Activate a command or checked item. |
| Escape / Tab | Close the applicable menu; Tab continues to the next control. |
Provide a meaningful accessible name and connect labels, hints and errors to the focusable element. Check the behavior with your own data and a screen reader.
WAI-ARIA Authoring PracticesIn your application, check keyboard controls, zoom and focus visibility. State labels and required information must be readable in every theme.