Menubar
A row of menus, like an app's File, Edit, and View
Primitive
A menubar sets an app's top-level menus side by side, like File, Edit, and View. Once one menu is open, moving across the bar opens the next, and a highlight glides to the open menu's trigger.
For one menu opened from a button, use DropdownMenu.
Preview
Installation
Usage
Composition
Add one MenubarMenu per top-level menu. The parts inside MenubarContent are Dropdown Menu's, under Menubar names.
Examples
Variants
Use variant to pick the shell the triggers sit on.
| Variant | Description |
|---|---|
elevated | The default. A raised surface. |
outline | An outline Button's fill and border. |
soft | A secondary Button's fill. |
ghost | No shell, for a bar in an app's header. |
Size
Use size to match the bar's height to a Button of the same size.
With Checkboxes and Switches
Use MenubarCheckboxItem for settings and MenubarRadioGroup for one choice; set indicator="switch" on a checkbox item for a switch.
Accessibility
Keyboard
Tab moves focus into and out of the bar in one stop. Arrow keys move between triggers, Down or Enter opens a menu, and Left and Right move to the next menu while one is open.
Highlight
The highlight follows the pointer, keyboard focus, and the open menu. Focus also draws a ring, so the highlight is never the only cue. With reduced motion, it jumps instead of sliding.
API Reference
The Menubar is built on top of Base UI's Menubar and Menu. All Base UI props are supported. The documentation below only covers custom props and modified defaults specific to our implementation.
For the complete Base UI API, see the Base UI Menubar documentation.
Props
Menubar
The shell around the triggers. Wraps Base UI's Menubar.
MenubarTrigger
Opens its menu. Wraps Base UI's Menu.Trigger.
MenubarContent
The menu's popup, aligned to the start of its trigger. Composes Menu.Portal, Menu.Positioner, Menu.Popup, and Menu.Viewport. Props are forwarded to Menu.Popup.
Notes
Menu parts
MenubarItem, MenubarCheckboxItem, MenubarRadioItem, MenubarSub, and the other parts inside MenubarContent are Dropdown Menu's. See the Dropdown Menu API for their props.
Upgrading
If you're reinstalling over an earlier version, check these changes:
| Before | Now |
|---|---|
Installed as cubby-ui/menubar.tsx | Installs into a cubby-ui/menubar/ folder with menubar.css, and installs Dropdown Menu. Import from @/components/ui/cubby-ui/menubar/menubar and delete the old file. |
level and shadowLevel on Menubar | Removed; use variant. MenubarContent keeps them. |
MenubarContent defaulted to sideOffset={8}, alignOffset={-4} | sideOffset={4}, alignOffset={0}, since triggers now reach the bar's edge. |
| Sub-menus opened after a 100ms hover delay | They open at once, as in Dropdown Menu. |