WlContextMenu
Placement
Material · Shift+F10
· Compact header: false
Full example
<div class="wl-stack" data-space="md">
<WlContextMenu
:items="items"
aria-label="Material actions"
data-context-example
>
<WlCard padding="md"><p>{{ "Material" }} · Shift+F10</p></WlCard>
</WlContextMenu>
<p role="status" class="wl-text-small">{{ selection }} · {{ "Compact header" }}: {{ compact }}</p>
</div>Context actions with nested choices
Pointer and keyboard context menu with nested and checked items.
Material · Shift+F10
· Compact header: false
Full example
<script setup lang="ts">
import { WlCard, WlContextMenu, type WlMenuItem } from "legato-ui";
import { computed, ref } from "vue";
const selection = ref("");
const compact = ref(false);
const items = computed<WlMenuItem[]>(() => [
{ label: "Edit", icon: "edit", command: () => { selection.value = "Editing"; } },
{ label: "View", items: [
{ label: "Compact header", type: "checkbox", checked: compact.value, onCheckedChange: (checked) => { compact.value = checked; } }
] },
{ label: "Unavailable", disabled: true },
{ separator: true },
{ label: "Delete", icon: "trash", danger: true, command: () => { selection.value = "Deletion"; } }
]);
</script>
<template>
<div class="wl-stack" data-space="md">
<WlContextMenu :items="items" aria-label="Material actions">
<WlCard padding="md"><p>{{ "Material" }} · Shift+F10</p></WlCard>
</WlContextMenu>
<p role="status" class="wl-text-small">{{ selection }} · {{ "Compact header" }}: {{ compact }}</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< | [] | Readonly item descriptors rendered by this component. |
disabled | boolean | false | Disable user interaction with this component. |
placement | WlPopoverPlacement | "bottom" | Preferred overlay side relative to its anchor. |
align | WlPopoverAlign | "start" | Alignment of the overlay along its anchor. |
ariaLabel | string | Not set | Accessible name when an external label is not referenced. |
ariaLabelledby | string | Not set | ID or space-separated IDs of elements naming this component. |
motion | boolean | Inherits WlConfig.motion | Enable motion locally, with application defaults and reduced-motion preferences respected. |
pt | WlPt< | Not set | Attributes and callbacks for the component's documented pass-through sections. |
menuPt | WlPt< | Not set | Pass-through attributes for the context menu's menu panel. |
Events
| Event | Payload | When emitted |
|---|---|---|
open | [] | Emitted when the surface opens. |
close | [] | Emitted when the surface closes. |
check | [event: WlMenuCheckEvent< | Emitted when a menu checkbox or radio item changes its checked state. |
Slots
| Slot | Type / values | Content |
|---|---|---|
default | default?(props: Record< | Content of the default focusable context-menu trigger. |
trigger | trigger?(props: WlMenuTriggerSlotProps): unknown; | Custom trigger; bind its supplied attributes and use the provided open/close actions. |
Pass-through: pt
Sections WlContextMenu 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-context-menu | Main element of the component. |
menuPt.root | div.wl-menu | Main element of the component. |
menuPt.list | ul.wl-menu__list | List of available items. |
menuPt.item | li.wl-menu__item | One repeated item. |
menuPt.submenuLabel | div.wl-menu__head | Non-interactive menu group heading. |
menuPt.separator | div.wl-menu__sep | Decorative separator between menu groups. |
menuPt.itemContent | div.wl-menu__item-content | Wrapper around the interactive menu item. |
menuPt.itemLink | button / a.wl-menu__link | Focusable menu action or link. |
menuPt.checkIcon | span.wl-menu__check | Decorative checkbox/radio state icon; checked state stays on the menu item. |
menuPt.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
- Name the trigger area and describe each available command.
- Nested menus expose menuitem, menuitemcheckbox and menuitemradio semantics. Checked state belongs to the application.
- Open with a context click, Shift+F10 or ContextMenu. Arrows enter and leave submenus; Escape returns focus to the trigger.
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. |
| Shift+F10 / ContextMenu | Open at the focused trigger. |
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.