Menubar
A horizontal bar of menus, like the menu bar of a desktop application.
Anatomy
The menubar owns only a root element. Its items are the triggers of the Menu components inside it.
<Menubar.Root>
<Menu.Root>
<Menu.Trigger />
<Portal>
<Menu.Positioner>
<Menu.Content>
<Menu.Item />
</Menu.Content>
</Menu.Positioner>
</Portal>
</Menu.Root>
</Menubar.Root>
Examples
Basic
Each Menu inside Menubar.Root becomes an item. The menubar handles roving tabindex, arrow keys, Home/End and
typeahead across the triggers. The menus coordinate opening and closing. No extra prop or wrapper is needed.
While a menu is open, moving to a sibling with the arrow keys or pointer switches to it.
Nested Menus
Submenus use Menu.TriggerItem as usual. ArrowRight on a submenu trigger opens the submenu instead of moving to the
next menu.
Vertical
Set orientation="vertical" to stack the triggers. Up and down move between them. ArrowRight opens the focused menu
as a fly-out.
Disabled
Set disabled on Menubar.Root to disable every trigger.
Set disabled on a Menu.Trigger to disable one menu. Keyboard navigation skips it, it is never tabbable, and hover
doesn't open it.
Root Provider
Use the useMenubar hook with Menubar.RootProvider to read state from outside the component.
Guides
Portal the menus
Render menu content in a Portal. The menubar treats every role="menuitem" inside its root as its own item. An inline
Menu.Positioner would have its items picked up as menubar triggers, and keyboard navigation would land on them.
<Menu.Root>
<Menu.Trigger>File</Menu.Trigger>
{/* ✅ portalled out of the menubar root */}
<Portal>
<Menu.Positioner>
<Menu.Content>{/* ... */}</Menu.Content>
</Menu.Positioner>
</Portal>
</Menu.Root>
Skipping the animation between menus
The first open should animate. Moving between menus is a swap, and replaying enter and exit animations there looks like flicker.
The outgoing and incoming content both get data-instant during a swap. Use it to skip the animation while keeping it
for the first open:
[data-menu-content][data-state='open'] {
animation: fade-in 150ms ease-out;
}
[data-menu-content][data-state='closed'] {
animation: fade-out 100ms ease-in;
}
/* switching between menus in a menubar */
[data-menu-content][data-instant] {
animation: none;
}
Arrow keys and hovering a sibling trigger set data-instant. Closing a menu by clicking its trigger or pressing
Escape clears it, so the next open animates.
API Reference
Props
Root
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
disabled | false | booleanWhether the menubar (and all its menu triggers) is disabled. |
ids | Partial<{ root: string }>The ids of the elements in the menubar. Useful for composition. | |
loopFocus | true | booleanWhether to loop the keyboard navigation across the triggers. |
orientation | 'horizontal' | OrientationThe orientation of the menubar. |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-menubar-root] | <uid> |
[data-orientation] | The orientation of the menubar |
[data-disabled] | Present when disabled |
[data-has-open-menu] | Present when a menu in the menubar is open |
RootProvider
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
value | UseMenubarReturn | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Context
API
| Property | Type |
|---|---|
hasOpenMenu | booleanWhether any menu within the menubar is open. |
orientation | OrientationThe orientation of the menubar. |
disabled | booleanWhether the menubar is disabled. |
getRootState | () => RootStateReturns the state of the root |
getMenuContext | () => MenubarMenuContextReturns the config to pass to each top-level menu's `menubar` prop. Adapters usually expose this via a context so nested `<Menu>`s can read it. |
Accessibility
Complies with the Menubar WAI-ARIA design pattern.
Keyboard Support
| Key | Description |
|---|---|
ArrowRightArrowLeft | In a horizontal menubar, moves focus to the next/previous menu. If a menu is open, opens the sibling menu. |
ArrowDownArrowUp | In a vertical menubar, moves focus to the next/previous menu. In a horizontal menubar, opens the focused menu. |
EnterSpace | Opens the focused menu and highlights its first item. |
HomeEnd | Moves focus to the first/last menu. |
Esc | Closes the open menu and returns focus to its trigger. |