Skip to content

Menu Button

Open a command menu from one trigger and restore focus on dismissal.

Usage

Action menu

Create or import workspace resources from one compact trigger.

Create or import workspace resources from one compact trigger.

Nested submenu

Keep secondary export formats inside the Export as command.

Keep secondary export formats inside the Export as command.

Controlled

Let the parent own the current value and apply accepted changes back to the component.

Let the parent own the current value and apply accepted changes back to the component.

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-button

Components
  • MenuButtonContent
  • MenuButtonRoot
  • MenuButtonTrigger
  • MenuItem
  • MenuSeparator
  • MenuSubContent

Props

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.

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.

Slots

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.

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.

Events

invoke

Emitted when the current action is invoked.

update:open

Emitted when the component requests a new open state.

Parts

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

PartSelectorRoleExtra attributes
trigger[data-part="trigger"]Opens, closes, or activates the associated content.
content[data-part="content"]Contains the component content shown for the active state.
item[data-part="item"]Menu item at any hierarchy depth; use data-level to distinguish top-level and nested itemsdata-scope="menu"
data-level="<depth>"
sub-content[data-part="sub-content"]Popup content owned by a parent menu itemdata-scope="menu"
data-level="<depth>"
separator[data-part="separator"]Separates related groups without becoming an action.data-scope="menu"

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

The trigger exposes popup and expanded state; the opened content uses menu semantics and returns focus on close.

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

Released under the MIT License.