Menubar
A visually persistent menu common in desktop applications that provides quick access to a consistent set of commands.
Installation
bash
npx shadcn@latest add @redpanda/menubarbash
pnpm dlx shadcn@latest add @redpanda/menubarbash
yarn dlx shadcn@latest add @redpanda/menubarbash
bunx shadcn@latest add @redpanda/menubarbash
nubx shadcn@latest add @redpanda/menubarbash
aube dlx shadcn@latest add @redpanda/menubarWhen to use
The Menubar component provides persistent menu access similar to desktop applications. Use this decision tree to determine when it’s appropriate:
Usage
tsx
import { Menubar, MenubarContent, MenubarItem, MenubarMenu, MenubarSeparator, MenubarShortcut, MenubarTrigger,} from '@/components/ui/menubar';tsx
<Menubar> <MenubarMenu> <MenubarTrigger>File</MenubarTrigger> <MenubarContent> <MenubarItem> New Tab <MenubarShortcut>⌘T</MenubarShortcut> </MenubarItem> <MenubarItem>New Window</MenubarItem> <MenubarSeparator /> <MenubarItem>Share</MenubarItem> <MenubarSeparator /> <MenubarItem>Print</MenubarItem> </MenubarContent> </MenubarMenu></Menubar>Examples
Checkbox items
Radio items
Nested submenus
Props
Keyboard interactions
| Key | Action |
|---|---|
Tab into the menubar |
Focus lands on the first top-level trigger. |
ArrowLeft / ArrowRight |
Moves between top-level menus. |
ArrowDown / Enter / Space |
Opens the focused menu and focuses its first item. |
ArrowUp / ArrowDown (inside a menu) |
Moves between items. |
ArrowLeft / ArrowRight (inside a menu) |
Opens / closes submenus and moves between adjacent menus. |
Home / End |
Jumps to first / last item. |
Enter / Space |
Activates the focused item. |
Escape |
Closes the open menu. |
| Typing a character | Typeahead jumps to the next matching item. |
Accessibility
- The menubar container has
role="menubar"and each top-level triggerrole="menuitem"witharia-haspopup="menu"andaria-expanded. - Focus is roving across both the menubar and each menu; only one trigger is in the tab order.
- Keep labels short and single-level where possible. Deeply nested submenus are hard to reach for motor-impaired
users — consider a
DropdownMenuwithkeepMountedpanels instead. - Open state lives on each child
MenubarMenu(setopen/onOpenChangethere), not on theMenubarroot.