Menubar
newFile, Edit, View. The bar your desktop apps have had since 1984, now in Vue.
Open Props in the corner of the example to try variant and size. outline frames the bar, soft fills it with the muted surface, and ghost drops both, for a header that already has a frame of its own. size sets the triggers and every menu in one go; items match the height of an Input of the same size, and a MenubarContent or MenubarSubContent with its own size wins.
Installation
Usage
<script setup lang="ts">
import {
Menubar,
MenubarContent,
MenubarItem,
MenubarMenu,
MenubarShortcut,
MenubarTrigger,
} from '@/components/ui/menubar'
</script>
<template>
<Menubar aria-label="Application">
<MenubarMenu>
<MenubarTrigger>File</MenubarTrigger>
<MenubarContent>
<MenubarItem @select="create">
New
<MenubarShortcut>⌘N</MenubarShortcut>
</MenubarItem>
<MenubarItem @select="open">Open…</MenubarItem>
</MenubarContent>
</MenubarMenu>
</Menubar>
</template>
A menubar is a row of menus. Click a trigger to open its menu; once one is open, hovering another trigger switches to it, the way desktop menus work. Menus never open on hover alone.
The menus are the same as Menu's: same items, sizes, state layers and shortcuts.
MenubarMenu: one menu, aMenubarTriggerplus aMenubarContentMenubarItem: an action; firesselectand closes the whole barMenubarCheckboxItem,MenubarRadioGroup+MenubarRadioItem: settingsMenubarSub,MenubarSubTrigger,MenubarSubContent: submenusMenubarLabel,MenubarGroup,MenubarSeparator: structureMenubarShortcut: a key hint at the end, display only
Use the Menubar* parts only. A MenuSubTrigger inside a menubar opens its submenu and jumps to the next menu on the same keypress.
Give the bar an aria-label. It's a desktop pattern: on small screens, a Menu or a DrawerMenu is kinder to thumbs.
Examples
Icons and states
Icons pick up the item size. inset lines plain items and labels up with checkbox and radio items. A disabled trigger is skipped by the arrow keys and never opens.
Checkbox and radio items
Bind MenubarCheckboxItem and MenubarRadioGroup with v-model. A closed menu is unmounted, so keep the state in your component, not in the items.
{
"wordWrap": true,
"minimap": false,
"lineNumbers": true,
"theme": "system"
}Open state
v-model on Menubar holds the value of the open menu, or "" when none is. Set it to open a menu from code. The open trigger has data-state="open", so style it with data-[state=open]:.
value doubles as the trigger's id, so pick something unique on the page, like menubar-file, or leave it out and let one be generated.
Dialogs and focus
An item can open a Dialog or an AlertDialog from @select. Bind the dialog's open yourself: the item is gone once the menu closes, so a trigger inside it would go with it. When the dialog closes, send focus back to the bar.
If an item moves focus elsewhere, like Find… here, focus stays there. To keep focus off the trigger in any other case, call preventDefault() in @close-auto-focus on MenubarContent. Reka UI ignores that on its own; the kappa component makes it work.
Editing Roadmap 2026.md
Icon triggers
Give an icon-only trigger a name with aria-label, or with v-tooltip.label, which shows it on hover too. Use the directive, not a Tooltip around the trigger: the component takes over the menu's anchor and the menu opens in the wrong place.
Right to left
With dir="rtl" on the bar, or from a ConfigProvider, the arrows run the other way, menus align to the trigger's right edge and submenu chevrons flip. Shortcuts stay left to right.
With a toolbar
A menubar holds menus and nothing else. For buttons and toggles at bar level, like Bold or Italic, use a Toolbar, and put a Menu in one of its buttons when you need a dropdown there.
The quick brown fox jumps over the lazy dog.
Known limits
- No actions or toggles at bar level: every trigger opens a menu (reka-ui#2048). Use a Toolbar.
- Horizontal only. Reka fixes the bar's orientation.
- A closed menu is unmounted, along with anything inside it (reka-ui#2057). Keep item state in your component, and use links, not a menubar, for navigation that search engines should see.
- A
Tooltipcomponent around a trigger breaks the menu's position (reka-ui#2993). Usev-tooltip. - Cancelling a trigger's
pointerdownorkeydownto stop the menu from opening needsreka-ui2.11 or later (reka-ui#2984). - In a
v-formenu, give items stable keys and don't build new prop objects on every render. Re-rendering items under the pointer can swallow a click in Chrome (reka-ui#2783). - The item highlight and focus ring follow the theme's state layer and ring tokens, which may fall below 3:1 against the menu on the default theme (nuxt/ui#6588).
API Reference
Every part takes a class that merges with its own. On MenubarContent and MenubarSubContent, it styles the panel.
Menubar
| Prop | Default | Type and description |
|---|---|---|
| modelValue | — | stringThe |
| defaultValue | — | stringThe menu open on first render, when you don't bind |
| dir | — | DirectionReading direction. In |
| loop | true | booleanLets the arrow keys wrap from the last menu to the first. On by default, unlike Reka. |
| size | "md" | MenuSizeSize of the triggers and, unless a menu sets its own, of every menu and submenu: |
| variant | "outline" | NonNullable<"outline" | "soft" | "ghost" | null | undefined>
|
| Event | Payload and description |
|---|---|
| update:modelValue | [value: string]Fires with the open menu's |
| Slot | Scope and description |
|---|---|
| default | { modelValue: string; }The |
MenubarMenu
| Prop | Default | Type and description |
|---|---|---|
| value | — | stringNames the menu for the bar's |
| Slot | Scope and description |
|---|---|
| default | {}A |
MenubarTrigger
| Prop | Default | Type and description |
|---|---|---|
| disabled | — | booleanDisables the menu: the arrow keys skip its trigger and it cannot open. |
| asChild | — | booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it. |
| as | — | AsTag | ComponentThe element or component to render. |
| Slot | Scope and description |
|---|---|
| default | {}The menu's name, an icon, or both. Give an icon-only trigger an |
MenubarContent
| Prop | Default | Type and description |
|---|---|---|
| forceMount | — | booleanKeeps the panel mounted while closed, for animating it with a JavaScript library. |
| memoDependencies | — | unknown[]Values that should re-run the position update when they change. |
| side | — | "top" | "right" | "bottom" | "left"The side of the trigger to open on. Flips to the other side when there is no room, unless |
| sideOffset | 4 | numberDistance in pixels from the trigger. |
| sideFlip | — | booleanFlips to the opposite side when the preferred one would overflow. |
| align | "start" | "start" | "center" | "end"Alignment against the trigger. |
| alignOffset | — | numberOffset in pixels from the |
| alignFlip | — | booleanFlips the alignment when it would overflow. |
| avoidCollisions | — | booleanKeeps the panel inside the collision boundary by flipping and shifting it. |
| collisionBoundary | — | Element | (Element | null)[] | nullThe element or elements used as the collision boundary. The viewport by default. |
| collisionPadding | 8 | number | Partial<Record<"top" | "right" | "bottom" | "left", number>>Distance in pixels from the boundary edges where collisions start. |
| arrowPadding | — | numberPadding between an arrow and the panel's corners. |
| hideShiftedArrow | — | booleanHides an arrow when the panel is shifted so far that the arrow would not point at the trigger. |
| sticky | — | "partial" | "always"
|
| hideWhenDetached | — | booleanHides the panel when the trigger is scrolled out of view. |
| positionStrategy | — | "absolute" | "fixed"The CSS position used to place the panel. |
| updatePositionStrategy | — | "always" | "optimized"
|
| disableUpdateOnLayoutShift | — | booleanStops recomputing the position when the layout shifts. |
| prioritizePosition | — | booleanKeeps the preferred side and alignment and lets the panel overflow instead of flipping. |
| reference | — | ReferenceElementA virtual element to position against instead of the trigger. |
| asChild | — | booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it. |
| as | — | AsTag | ComponentThe element or component to render. |
| loop | — | booleanWraps the up and down arrows from the last item to the first. |
| size | — | MenuSizeItem size, from |
| Event | Payload and description |
|---|---|
| escapeKeyDown | [event: KeyboardEvent]Fires on Escape. Call |
| pointerDownOutside | [event: PointerDownOutsideEvent]Fires on a pointer press outside. Call |
| focusOutside | [event: FocusOutsideEvent]Fires when focus moves outside. Call |
| interactOutside | [event: PointerDownOutsideEvent | FocusOutsideEvent]Fires on any press or focus outside. Call |
| openAutoFocus | [event: Event]Fires when focus moves into the menu on open. Call |
| closeAutoFocus | [event: Event]Fires when focus would return to the trigger on close. Call |
| Slot | Scope and description |
|---|---|
| default | {}The items. |
MenubarItem
| Prop | Default | Type and description |
|---|---|---|
| disabled | — | booleanDisables the item: it is skipped by the keyboard and cannot be chosen. |
| textValue | — | stringText used for typeahead instead of the item's text content. |
| asChild | — | booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it. |
| as | — | AsTag | ComponentThe element or component to render. |
| inset | — | booleanIndents the text to line up with items that have an indicator. |
| color | — | MenuItemColor | (string & {})Colour role the item, its icon and its hover layer are drawn in, such as |
| Event | Payload and description |
|---|---|
| select | [event: Event]Fires when the item is chosen by click or keyboard. Call |
| Slot | Scope and description |
|---|---|
| default | {}The label, with an optional leading icon and a |
MenubarCheckboxItem
| Prop | Default | Type and description |
|---|---|---|
| modelValue | — | CheckedStateWhether it is checked, bound with |
| disabled | — | booleanDisables the item: it is skipped by the keyboard and cannot be chosen. |
| textValue | — | stringText used for typeahead instead of the item's text content. |
| asChild | — | booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it. |
| as | — | AsTag | ComponentThe element or component to render. |
| Event | Payload and description |
|---|---|
| select | [event: Event]Fires when the item is chosen by click or keyboard. Call |
| update:modelValue | [payload: boolean]Fires when the item is toggled. |
| Slot | Scope and description |
|---|---|
| indicator-icon | {}The icon shown while checked, a check by default. |
| default | { checked: CheckedState; modelValue: CheckedState; }The label. Receives |
MenubarRadioGroup
| Prop | Default | Type and description |
|---|---|---|
| modelValue | — | AcceptableValueThe value of the checked item, bound with |
| asChild | — | booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it. |
| as | — | AsTag | ComponentThe element or component to render. |
| Event | Payload and description |
|---|---|
| update:modelValue | [payload: AcceptableValue]Fires when another item is checked. |
| Slot | Scope and description |
|---|---|
| default | {}The radio items. |
MenubarRadioItem
| Prop | Default | Type and description |
|---|---|---|
| value* | — | AcceptableValueThe value this item puts in the group's |
| disabled | — | booleanDisables the item: it is skipped by the keyboard and cannot be chosen. |
| textValue | — | stringText used for typeahead instead of the item's text content. |
| asChild | — | booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it. |
| as | — | AsTag | ComponentThe element or component to render. |
| Event | Payload and description |
|---|---|
| select | [event: Event]Fires when the item is chosen by click or keyboard. Call |
| Slot | Scope and description |
|---|---|
| indicator-icon | {}The icon shown while checked, a dot by default. |
| default | { checked: boolean; }The label. Receives |
MenubarItemIndicator
| Prop | Default | Type and description |
|---|---|---|
| forceMount | — | booleanKeeps the indicator mounted while unchecked, for animating it. Needs |
| asChild | — | booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it. |
| as | — | AsTag | ComponentThe element or component to render. |
| Slot | Scope and description |
|---|---|
| default | {}The mark shown while the item is checked. Checkbox and radio items already render one. |
MenubarLabel
| Prop | Default | Type and description |
|---|---|---|
| asChild | — | booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it. |
| as | — | AsTag | ComponentThe element or component to render. |
| inset | — | booleanIndents the text to line up with items that have an indicator. |
| Slot | Scope and description |
|---|---|
| default | {}The label text. |
MenubarSeparator
| Prop | Default | Type and description |
|---|---|---|
| asChild | — | booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it. |
| as | — | AsTag | ComponentThe element or component to render. |
MenubarShortcut
| Slot | Scope and description |
|---|---|
| default | {}The key combination, for display only. It does not register the shortcut. |
MenubarGroup
| Prop | Default | Type and description |
|---|---|---|
| asChild | — | booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it. |
| as | — | AsTag | ComponentThe element or component to render. |
| Slot | Scope and description |
|---|---|
| default | {}Related items. |
MenubarSub
| Prop | Default | Type and description |
|---|---|---|
| defaultOpen | — | booleanWhether it starts open, when you don't bind |
| open | — | booleanWhether it is open, bound with |
| Event | Payload and description |
|---|---|
| update:open | [payload: boolean]Fires when it opens or closes. |
| Slot | Scope and description |
|---|---|
| default | { open: boolean; }A |
MenubarSubTrigger
| Prop | Default | Type and description |
|---|---|---|
| graceDuration | — | numberHow long, in milliseconds, the pointer has to reach the submenu after leaving this item. |
| disabled | — | booleanDisables the item: it is skipped by the keyboard and cannot be chosen. |
| textValue | — | stringText used for typeahead instead of the item's text content. |
| asChild | — | booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it. |
| as | — | AsTag | ComponentThe element or component to render. |
| inset | — | booleanIndents the text to line up with items that have an indicator. |
| Slot | Scope and description |
|---|---|
| default | {}The label of the item that opens the submenu. |
MenubarSubContent
| Prop | Default | Type and description |
|---|---|---|
| forceMount | — | booleanKeeps the panel mounted while closed, for animating it with a JavaScript library. |
| memoDependencies | — | unknown[]Values that should re-run the position update when they change. |
| sideOffset | — | numberDistance in pixels from the trigger. |
| sideFlip | — | booleanFlips to the opposite side when the preferred one would overflow. |
| alignOffset | — | numberOffset in pixels from the |
| alignFlip | — | booleanFlips the alignment when it would overflow. |
| avoidCollisions | — | booleanKeeps the panel inside the collision boundary by flipping and shifting it. |
| collisionBoundary | — | Element | (Element | null)[] | nullThe element or elements used as the collision boundary. The viewport by default. |
| collisionPadding | 8 | number | Partial<Record<"top" | "right" | "bottom" | "left", number>>Distance in pixels from the boundary edges where collisions start. |
| arrowPadding | — | numberPadding between an arrow and the panel's corners. |
| hideShiftedArrow | — | booleanHides an arrow when the panel is shifted so far that the arrow would not point at the trigger. |
| sticky | — | "partial" | "always"
|
| hideWhenDetached | — | booleanHides the panel when the trigger is scrolled out of view. |
| positionStrategy | — | "absolute" | "fixed"The CSS position used to place the panel. |
| updatePositionStrategy | — | "always" | "optimized"
|
| disableUpdateOnLayoutShift | — | booleanStops recomputing the position when the layout shifts. |
| prioritizePosition | — | booleanKeeps the preferred side and alignment and lets the panel overflow instead of flipping. |
| reference | — | ReferenceElementA virtual element to position against instead of the trigger. |
| asChild | — | booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it. |
| as | — | AsTag | ComponentThe element or component to render. |
| loop | — | booleanWraps the up and down arrows from the last item to the first. |
| size | — | MenuSizeItem size, from |
| Event | Payload and description |
|---|---|
| entryFocus | [event: Event]Fires when focus enters the submenu. Call |
| escapeKeyDown | [event: KeyboardEvent]Fires on Escape. Call |
| pointerDownOutside | [event: PointerDownOutsideEvent]Fires on a pointer press outside. Call |
| focusOutside | [event: FocusOutsideEvent]Fires when focus moves outside. Call |
| interactOutside | [event: PointerDownOutsideEvent | FocusOutsideEvent]Fires on any press or focus outside. Call |
| openAutoFocus | [event: Event]Fires when focus moves into the menu on open. Call |
| closeAutoFocus | [event: Event]Fires when focus would return to the trigger on close. Call |
| Slot | Scope and description |
|---|---|
| default | {}The submenu's items. |
Props
- modelValue
stringThevalueof the open menu, bound withv-model.""when every menu is closed.- defaultValue
stringThe menu open on first render, when you don't bindv-model.- dir
DirectionReading direction. Inrtlthe left and right arrows run the other way and menus align to the trigger's right edge.- loop
true booleanLets the arrow keys wrap from the last menu to the first. On by default, unlike Reka.- size
"md" MenuSizeSize of the triggers and, unless a menu sets its own, of every menu and submenu:xstoxl.- variant
"outline" NonNullable<"outline" | "soft" | "ghost" | null | undefined>outlineframes the bar with a border;softfills it with the muted surface;ghostis a bare row, for a header that already has a frame.
Emits
- update:modelValue
[value: string]Fires with the open menu'svaluewhen one opens or the bar switches menus, and with""when the last one closes.
Slots
- default
{ modelValue: string; }TheMenubarMenus. ReceivesmodelValue.
Props
- value
stringNames the menu for the bar'sv-model. Generated when left out. It also becomes the trigger'sid, so make it unique on the page, likemenubar-file.
Slots
- default
{}AMenubarTriggerand aMenubarContent.
Props
- disabled
booleanDisables the menu: the arrow keys skip its trigger and it cannot open.- asChild
booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it.- as
AsTag | ComponentThe element or component to render.
Slots
- default
{}The menu's name, an icon, or both. Give an icon-only trigger anaria-labelor av-tooltip.label.
Props
- forceMount
booleanKeeps the panel mounted while closed, for animating it with a JavaScript library.- memoDependencies
unknown[]Values that should re-run the position update when they change.- side
"top" | "right" | "bottom" | "left"The side of the trigger to open on. Flips to the other side when there is no room, unlessavoidCollisionsis off.- sideOffset
4 numberDistance in pixels from the trigger.- sideFlip
booleanFlips to the opposite side when the preferred one would overflow.- align
"start" "start" | "center" | "end"Alignment against the trigger.startby default, so the menu lines up with the trigger's start edge.- alignOffset
numberOffset in pixels from thealignposition.- alignFlip
booleanFlips the alignment when it would overflow.- avoidCollisions
booleanKeeps the panel inside the collision boundary by flipping and shifting it.- collisionBoundary
Element | (Element | null)[] | nullThe element or elements used as the collision boundary. The viewport by default.- collisionPadding
8 number | Partial<Record<"top" | "right" | "bottom" | "left", number>>Distance in pixels from the boundary edges where collisions start.- arrowPadding
numberPadding between an arrow and the panel's corners.- hideShiftedArrow
booleanHides an arrow when the panel is shifted so far that the arrow would not point at the trigger.- sticky
"partial" | "always"partialkeeps the panel attached to the trigger while scrolling;alwaysalso lets it detach from the trigger to stay in the boundary.- hideWhenDetached
booleanHides the panel when the trigger is scrolled out of view.- positionStrategy
"absolute" | "fixed"The CSS position used to place the panel.- updatePositionStrategy
"always" | "optimized"alwaysrecomputes the position on every animation frame instead of only on layout changes.- disableUpdateOnLayoutShift
booleanStops recomputing the position when the layout shifts.- prioritizePosition
booleanKeeps the preferred side and alignment and lets the panel overflow instead of flipping.- reference
ReferenceElementA virtual element to position against instead of the trigger.- asChild
booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it.- as
AsTag | ComponentThe element or component to render.- loop
booleanWraps the up and down arrows from the last item to the first.- size
MenuSizeItem size, fromxstoxl. Defaults to the menubar's size.
Emits
- escapeKeyDown
[event: KeyboardEvent]Fires on Escape. CallpreventDefault()to keep it open.- pointerDownOutside
[event: PointerDownOutsideEvent]Fires on a pointer press outside. CallpreventDefault()to keep it open.- focusOutside
[event: FocusOutsideEvent]Fires when focus moves outside. CallpreventDefault()to keep it open.- interactOutside
[event: PointerDownOutsideEvent | FocusOutsideEvent]Fires on any press or focus outside. CallpreventDefault()to keep it open.- openAutoFocus
[event: Event]Fires when focus moves into the menu on open. CallpreventDefault()to keep focus where it is.- closeAutoFocus
[event: Event]Fires when focus would return to the trigger on close. CallpreventDefault()to leave focus where it is, for example on a field an item focused.
Slots
- default
{}The items.
Props
- disabled
booleanDisables the item: it is skipped by the keyboard and cannot be chosen.- textValue
stringText used for typeahead instead of the item's text content.- asChild
booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it.- as
AsTag | ComponentThe element or component to render.- inset
booleanIndents the text to line up with items that have an indicator.- color
MenuItemColor | (string & {})Colour role the item, its icon and its hover layer are drawn in, such asdestructivefor actions that delete or cannot be undone. Any other name picks up a colour you declare on[data-slot][data-color="<name>"].
Emits
- select
[event: Event]Fires when the item is chosen by click or keyboard. Callevent.preventDefault()to keep the menu open.
Slots
- default
{}The label, with an optional leading icon and aMenubarShortcut.
Props
- modelValue
CheckedStateWhether it is checked, bound withv-model.indeterminateshows the indicator too.- disabled
booleanDisables the item: it is skipped by the keyboard and cannot be chosen.- textValue
stringText used for typeahead instead of the item's text content.- asChild
booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it.- as
AsTag | ComponentThe element or component to render.
Emits
- select
[event: Event]Fires when the item is chosen by click or keyboard. Callevent.preventDefault()to keep the menu open.- update:modelValue
[payload: boolean]Fires when the item is toggled.
Slots
- indicator-icon
{}The icon shown while checked, a check by default.- default
{ checked: CheckedState; modelValue: CheckedState; }The label. Receivescheckedwithreka-ui2.11 or later.
Props
- modelValue
AcceptableValueThe value of the checked item, bound withv-model.- asChild
booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it.- as
AsTag | ComponentThe element or component to render.
Emits
- update:modelValue
[payload: AcceptableValue]Fires when another item is checked.
Slots
- default
{}The radio items.
Props
- value*
AcceptableValueThe value this item puts in the group'sv-model.- disabled
booleanDisables the item: it is skipped by the keyboard and cannot be chosen.- textValue
stringText used for typeahead instead of the item's text content.- asChild
booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it.- as
AsTag | ComponentThe element or component to render.
Emits
- select
[event: Event]Fires when the item is chosen by click or keyboard. Callevent.preventDefault()to keep the menu open.
Slots
- indicator-icon
{}The icon shown while checked, a dot by default.- default
{ checked: boolean; }The label. Receivescheckedwithreka-ui2.11 or later.
Props
- forceMount
booleanKeeps the indicator mounted while unchecked, for animating it. Needsreka-ui2.11 or later.- asChild
booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it.- as
AsTag | ComponentThe element or component to render.
Slots
- default
{}The mark shown while the item is checked. Checkbox and radio items already render one.
Props
- asChild
booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it.- as
AsTag | ComponentThe element or component to render.- inset
booleanIndents the text to line up with items that have an indicator.
Slots
- default
{}The label text.
Props
- asChild
booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it.- as
AsTag | ComponentThe element or component to render.
Slots
- default
{}The key combination, for display only. It does not register the shortcut.
Props
- asChild
booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it.- as
AsTag | ComponentThe element or component to render.
Slots
- default
{}Related items.
Props
- defaultOpen
booleanWhether it starts open, when you don't bindv-model:open.- open
booleanWhether it is open, bound withv-model:open.
Emits
- update:open
[payload: boolean]Fires when it opens or closes.
Slots
- default
{ open: boolean; }AMenubarSubTriggerand aMenubarSubContent. Receivesopen.
Props
- graceDuration
numberHow long, in milliseconds, the pointer has to reach the submenu after leaving this item.300by default. Needsreka-ui2.11 or later.- disabled
booleanDisables the item: it is skipped by the keyboard and cannot be chosen.- textValue
stringText used for typeahead instead of the item's text content.- asChild
booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it.- as
AsTag | ComponentThe element or component to render.- inset
booleanIndents the text to line up with items that have an indicator.
Slots
- default
{}The label of the item that opens the submenu.
Props
- forceMount
booleanKeeps the panel mounted while closed, for animating it with a JavaScript library.- memoDependencies
unknown[]Values that should re-run the position update when they change.- sideOffset
numberDistance in pixels from the trigger.- sideFlip
booleanFlips to the opposite side when the preferred one would overflow.- alignOffset
numberOffset in pixels from thealignposition.- alignFlip
booleanFlips the alignment when it would overflow.- avoidCollisions
booleanKeeps the panel inside the collision boundary by flipping and shifting it.- collisionBoundary
Element | (Element | null)[] | nullThe element or elements used as the collision boundary. The viewport by default.- collisionPadding
8 number | Partial<Record<"top" | "right" | "bottom" | "left", number>>Distance in pixels from the boundary edges where collisions start.- arrowPadding
numberPadding between an arrow and the panel's corners.- hideShiftedArrow
booleanHides an arrow when the panel is shifted so far that the arrow would not point at the trigger.- sticky
"partial" | "always"partialkeeps the panel attached to the trigger while scrolling;alwaysalso lets it detach from the trigger to stay in the boundary.- hideWhenDetached
booleanHides the panel when the trigger is scrolled out of view.- positionStrategy
"absolute" | "fixed"The CSS position used to place the panel.- updatePositionStrategy
"always" | "optimized"alwaysrecomputes the position on every animation frame instead of only on layout changes.- disableUpdateOnLayoutShift
booleanStops recomputing the position when the layout shifts.- prioritizePosition
booleanKeeps the preferred side and alignment and lets the panel overflow instead of flipping.- reference
ReferenceElementA virtual element to position against instead of the trigger.- asChild
booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it.- as
AsTag | ComponentThe element or component to render.- loop
booleanWraps the up and down arrows from the last item to the first.- size
MenuSizeItem size, fromxstoxl. Defaults to the size of the menu the submenu opens from.
Emits
- entryFocus
[event: Event]Fires when focus enters the submenu. CallpreventDefault()to keep the first item from being highlighted.- escapeKeyDown
[event: KeyboardEvent]Fires on Escape. CallpreventDefault()to keep it open.- pointerDownOutside
[event: PointerDownOutsideEvent]Fires on a pointer press outside. CallpreventDefault()to keep it open.- focusOutside
[event: FocusOutsideEvent]Fires when focus moves outside. CallpreventDefault()to keep it open.- interactOutside
[event: PointerDownOutsideEvent | FocusOutsideEvent]Fires on any press or focus outside. CallpreventDefault()to keep it open.- openAutoFocus
[event: Event]Fires when focus moves into the menu on open. CallpreventDefault()to keep focus where it is.- closeAutoFocus
[event: Event]Fires when focus would return to the trigger on close. CallpreventDefault()to leave focus where it is, for example on a field an item focused.
Slots
- default
{}The submenu's items.
Data attributes
| data-slot | Attributes | Description |
|---|---|---|
| menubar | data-size, data-variant | The bar, a role="menubar". Both are set even at their defaults, md and outline. |
| menubar-trigger | data-state, data-highlighted, data-disabled, aria-expanded | A menu's button, a role="menuitem". data-state is open while its menu is. |
| menubar-content | data-state, data-side, data-align, data-size | A menu's panel, a role="menu" named by its trigger. |
| menubar-item | data-highlighted, data-disabled, data-inset, data-color | An item. data-color carries its color. |
| menubar-checkbox-item | data-state, data-highlighted, data-disabled | A checkbox item. data-state is checked, unchecked or indeterminate. |
| menubar-radio-group | — | A role="group" of radio items. |
| menubar-radio-item | data-state, data-highlighted, data-disabled | A radio item. |
| menubar-item-indicator | data-state | The check or dot of a checked item. |
| menubar-label | data-inset | A label for the items after it. |
| menubar-separator | — | A line between groups. |
| menubar-group | — | Related items. |
| menubar-shortcut | — | A key combination at the end of an item. |
| menubar-sub-trigger | data-state, data-highlighted, data-disabled, data-inset | The item that opens a submenu. |
| menubar-sub-content | data-state, data-side, data-size | A submenu's panel. |
Accessibility
The bar is one tab stop. Inside it, the arrow keys move between triggers and wrap around by default. Each trigger is a role="menuitem" with aria-haspopup="menu" and aria-expanded, and points at its menu with aria-controls while it's open. The menu is named by its trigger.
Menus are never modal: the page stays live, nothing is hidden from screen readers, and Tab leaves an open menu. Reka's menus would send Tab from the end of the page, since they're portaled there; the kappa parts send it on from the bar, so it reaches the control right after it, or before it with Shift + Tab.
| Key | Action |
|---|---|
| Tab / Shift + Tab | Moves into the bar, onto the last used trigger, and out again. From an open menu, closes it and moves on from the bar. |
| ArrowRight / ArrowLeft | On a trigger, moves to the next or previous one. In a menu, opens the next or previous menu, or opens a submenu from its trigger. In a submenu, ArrowLeft closes it and goes back to its trigger. Reversed in right to left. |
| Home / End | Moves to the first or last trigger, or the first or last item. |
| Enter / Space | Opens the trigger's menu and focuses its first item. On an item, chooses it. |
| ArrowDown | Opens the trigger's menu and focuses its first item. In a menu, moves to the next item. |
| ArrowUp | Moves to the previous item. Does nothing on a closed trigger. |
| Escape | Closes the menu, or just the submenu, and focuses its trigger. |
| A–Z | Moves to the next item starting with that letter. |