A menu of actions opened by a button, with submenus, roving focus and typeahead, non-modal by default, following the APG menu button pattern in each framework.
A list of actions opened by a button, with nested submenus. The highlighted item is the focused
one (roving focus), typing jumps to an item, and each level is a layer. It follows the WAI-ARIA
APG menu button pattern: non-modal by
default, with a modal option that locks the page's scroll and blocks the pointer outside.
Its items may be actions, checkbox items and radio items. A menu opened at the pointer from an
area is a ContextMenu; a bar of menus is a Menubar,
whose items are Menu Triggers.
Open: ArrowDown, Enter or Space on the Trigger opens it on the first item, ArrowUp on the
last; a press opens it with the popup focused and no item highlighted.
Inside: ArrowDown and ArrowUp move (wrapping with loopFocus), Home and End jump, a typed
character moves to the next item that starts with it. A disabled item stays focusable but is
never activated (APG). Hovering an item highlights it.
Activate: Enter, Space or a click fires the item's click, then closes every level
(reason item-press) and focuses the trigger.
Checkbox and radio items: Space toggles a CheckboxItem (checks a RadioItem) and keeps the
menu open; Enter toggles it and closes every level (APG); a click toggles it and closes only
with closeOnClick (default false, Base UI). Each change reports onCheckedChange or the
RadioGroup's onValueChange with the reason item-press. An indicator renders only while its
item is checked, unless keepMounted.
Submenus: ArrowRight (ArrowLeft in RTL), Enter or Space on a SubmenuTrigger opens its
submenu on its first item, hovering it opens it after delay; ArrowLeft closes it. While the
pointer travels to an open submenu, crossing other items does not close it (a safe area).
Close: Escape closes one level (escape-key), focus back on its trigger. Tab closes every
level (focus-out) and moves on from the trigger. A press outside closes them all
(outside-press).
Modal (modal): while open, the page does not scroll and a press outside reaches no
element of the page: it only closes the menu, focus back on the trigger. The keyboard is
unchanged.
Layers: each level is a layer of the nested overlay tree: a
submenu is a child of its menu, and a menu opened from a popover or a dialog is that overlay's
child, so a press inside the parent closes the menu only.
Detached triggers: Triggers anywhere in the page open the same Root through a handle,
each with a payload (detached triggers). The menu anchors to
the active trigger and its popup is labelled by it; a press on another trigger while open moves
the menu there (it stays open, with the new payload).
Lifecycle: onOpenChangeComplete(open) reports the end of each transition, the actions
close() and unmount() act from code, and the Portal's keepMounted keeps the Positioner in
the page while closed (hidden, data-closed).
Every part also takes what the primitive contract gives:
render (Vue: as and the render slot), a class and a style, a ref, and any attribute, which
it forwards. The names below are React's; Vue binds them the same way (v-model:open,
@open-change, :loop-focus), and Angular as inputs and outputs ([(open)],
(openChangeDetails), [loopFocus]). An item's activation is its click event (onClick,
@click, (click)). A CheckboxItem binds v-model:checked (@checked-change) in Vue and
[(checked)] in Angular, whose (checkedChangeDetails) emits { value, details }; a RadioGroup
v-model:value and [(value)], (valueChangeDetails).
every change, with its reason (trigger-press, list-navigation, item-press, escape-key, outside-press, focus-out); called before the change, details.cancel() stops it
onOpenChangeComplete
(open: boolean) => void
once an opening or a closing has finished its transitions (not on the first render, nor for an exit a reopening interrupted)
actionsRef (react)
{ current: OverlayActions | null }
receives close() (reason imperative-action) and unmount() (ends an exit now); Vue exposes them on the Root's template ref, Angular as the root directive's methods
aria-haspopup="menu", aria-expanded ("true" on the active trigger while open), aria-controls (the popup, on the active trigger while open), data-popup-open (the active trigger), data-disabled, an id
Positioner
role="presentation", data-side, data-align, data-open / data-closed, data-nested (a submenu); hidden while kept mounted and closed
Popup
role="menu", aria-labelledby (the active trigger), aria-orientation="vertical", tabindex="-1", data-side, data-align, data-open / data-closed, data-nested, data-starting-style, data-ending-style
as an Item, plus aria-haspopup="menu", aria-expanded, aria-controls, data-popup-open
CheckboxItem
role="menuitemcheckbox", tabindex="-1", aria-checked, data-checked / data-unchecked, data-highlighted, aria-disabled and data-disabled
RadioGroup
role="group", data-disabled; named by your aria-label, or a Group's GroupLabel around it
RadioItem
role="menuitemradio", tabindex="-1", aria-checked, data-checked / data-unchecked, data-highlighted, aria-disabled and data-disabled (itself or its group)