Skip to content

Menu

Navigate hierarchical commands, open submenus, and invoke an action.

Usage

Command list

Run common project commands from one flat command list.

Run common project commands from one flat command list.

Disabled

Remove the control from keyboard and pointer interaction.

Remove the control from keyboard and pointer interaction.

Nested submenu

Choose an export format from a submenu owned by the Export command.

Choose an export format from a submenu owned by the Export command.

Floating positioning

This component uses the shared positioning engine. Use the live positioning example to change side, align, offsets, collision boundaries, strategy, and tracking while inspecting the resolved placement.

API

Vue package: @sectile/vue/menu

Components
  • MenuRoot
  • MenubarRoot
  • NavigationMenuRoot
  • MenuButtonRoot
  • MenuButtonTrigger
  • MenuButtonContent
  • MenuItem
  • MenuSubContent
  • MenuSeparator

Props

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

defaultHighlightedValue

Initially highlighted value for uncontrolled state.

disabled

Whether interaction is unavailable.

disabledItems

Item values excluded from focus and selection.

items

Ordered item values managed by the component.

label

Accessible name announced for the control.

policies

Behavior policies that customize validation, movement, or selection.

textValue

Returns searchable or presentational text for an item value.

align

Alignment of positioned content relative to its anchor.

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

avoidCollisions

Whether positioned content may flip or shift to remain visible.

collisionBoundary

Boundary used to keep positioned content visible.

collisionPadding

Space kept between positioned content and its collision boundary.

defaultHighlightedValue

Initially highlighted value for uncontrolled state.

defaultOpen

Initial uncontrolled open state.

disabled

Whether interaction is unavailable.

disabledItems

Item values excluded from focus and selection.

hideWhenDetached

Whether positioned content hides when its anchor leaves the layout.

items

Ordered item values managed by the component.

label

Accessible name announced for the control.

open

Whether the associated popup or disclosure is open.

policies

Behavior policies that customize validation, movement, or selection.

position

Whether the popup is positioned relative to its trigger.

side

Preferred side of the anchor for positioned content.

sideOffset

Distance between positioned content and its anchor.

strategy

CSS positioning strategy used for anchored content.

textValue

Returns searchable or presentational text for an item value.

tracking

Update strategy used while anchored content is open.

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

disabled

Whether interaction is unavailable.

value

Current value exposed by this contract.

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

for

Value or ID of the related part targeted by this component.

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

Slots

disabled

Whether interaction is unavailable.

highlightedValue

Value currently highlighted for interaction.

open

Whether the associated popup or disclosure is open.

openPath

Ordered values in the open menu path.

disabled

Whether interaction is unavailable.

highlighted

Whether this item is highlighted for interaction.

open

Whether the associated popup or disclosure is open.

value

Current value exposed by this contract.

Events

invoke

Emitted when the current action is invoked.

update:open

Emitted when the component requests a new open state.

invoke

Emitted when the current action is invoked.

update:open

Emitted when the component requests a new open state.

invoke

Emitted when the current action is invoked.

update:open

Emitted when the component requests a new open state.

invoke

Emitted when the current action is invoked.

update:open

Emitted when the component requests a new open state.

Other types

ts
type MenuTextValueResolver = NonNullable<MenuRootProps['textValue']>
ts
type MenuOpenChangeHandler = NonNullable<InstanceType<typeof MenuRoot>['$props']['onUpdate:open']>
ts
type MenuInvokeHandler = NonNullable<InstanceType<typeof MenuRoot>['$props']['onInvoke']>
ts
type MenubarOpenChangeHandler = NonNullable<InstanceType<typeof MenubarRoot>['$props']['onUpdate:open']>
ts
type MenubarInvokeHandler = NonNullable<InstanceType<typeof MenubarRoot>['$props']['onInvoke']>
ts
type NavigationMenuOpenChangeHandler = NonNullable<InstanceType<typeof NavigationMenuRoot>['$props']['onUpdate:open']>
ts
type NavigationMenuInvokeHandler = NonNullable<InstanceType<typeof NavigationMenuRoot>['$props']['onInvoke']>
ts
type MenuButtonOpenChangeHandler = NonNullable<InstanceType<typeof MenuButtonRoot>['$props']['onUpdate:open']>
ts
type MenuButtonInvokeHandler = NonNullable<InstanceType<typeof MenuButtonRoot>['$props']['onInvoke']>

Parts

Shared scope: [data-scope="menu"]. Combine it with a part selector to keep styles local to this component.

PartSelectorRoleExtra attributes
root[data-part="root"]Defines the component boundary and owns its composed parts.
item[data-part="item"]Menu item at any hierarchy depth; use data-level to distinguish top-level and nested itemsdata-level="<depth>"
sub-content[data-part="sub-content"]Popup content owned by a parent menu itemdata-level="<depth>"
separator[data-part="separator"]Separates related groups without becoming an action.

Keyboard interaction

KeyBehavior
Arrow Up / Arrow DownMove between items at the current menu level.
Arrow Right / Arrow LeftOpen a submenu or return to its parent.
Home / EndMove to the first or last item at the current level.
Enter / SpaceOpen a submenu or invoke the current item.
EscapeClose the current menu level.

Accessibility

Menu items, separators, and nested menu state use hierarchical menu semantics and roving focus.

See the corresponding WAI-ARIA pattern for the host accessibility contract.

Released under the MIT License.