Menubar
Horizontal menu bar with dropdowns, checkboxes, radio items, and keyboard navigation.
Examples
Usage
The minimal import and composition — see Examples below for styled, real-world variants.
import { Menubar, MenubarContent, MenubarItem, MenubarMenu, MenubarTrigger } from "@codefast/ui/menubar";
export function MenubarUsage() {
return (
<Menubar>
<MenubarMenu>
<MenubarTrigger>File</MenubarTrigger>
<MenubarContent>
<MenubarItem>New Tab</MenubarItem>
<MenubarItem>New Window</MenubarItem>
</MenubarContent>
</MenubarMenu>
</Menubar>
);
}
Anatomy
How the parts nest — every slot the component exposes, in composition order.
Features
- Multiple MenubarMenu siblings share roving focus — Left/Right arrow moves between top-level menus, Down opens the focused one.
- Supports the same item types as Dropdown Menu and Context Menu — checkbox items, a radio group, submenus, and destructive variants.
- Best suited to desktop; on mobile or touch, prefer a Dropdown Menu or Sheet instead.
API reference
Props for each part of the component. All native element props are also forwarded.
Menubar
The horizontal bar that hosts roving focus across its top-level menus.
valuestringControlled value of the currently open menu.
defaultValuestringUncontrolled initial value of the open menu.
onValueChange(value: string) => voidCalled when the open menu changes.
loopbooleanWhether arrow-key navigation loops from the last menu back to the first.
childrenReactNodeOne MenubarMenu per top-level menu (File, Edit…).
MenubarMenu
One top-level menu — pairs a MenubarTrigger with its MenubarContent.
valuestringIdentifies this menu; required when Menubar's value/onValueChange are controlled.
childrenReactNodeA MenubarTrigger and its MenubarContent.
MenubarItem
A single command row inside MenubarContent.
insetbooleanAdds start padding to align with items that have an icon or indicator.
Default
falsevariant"default" | "destructive"Use destructive for irreversible actions.
Default
"default"childrenReactNodeLabel text, optionally followed by a MenubarShortcut.
MenubarShortcut
Right-aligned key-hint text within a MenubarItem.
childrenReactNodeThe shortcut label, e.g. '⌘S'.
Accessibility
Built to be keyboard-navigable and screen-reader friendly out of the box.
| Key | Function |
|---|---|
| Arrow+Left | Moves between top-level menus. |
| Arrow+Down | Opens / moves down a menu. |
| Enter | Activates the focused item. |
| Esc | Closes the open menu. |
- Implements the ARIA menubar pattern with roving focus.
- Best on desktop; on mobile prefer a Dropdown Menu or Sheet.
- Mirror essential commands elsewhere — don’t hide them only here.
Guidelines
Conventions that keep usage consistent across an app.
Do
- Group commands the way a desktop app would (File, Edit, View).
- Show shortcuts so power users learn them.
Don’t
- Don’t use a menubar as primary site navigation.
- Don’t nest menus deeply.
Explore further
Ready to integrate?
Follow the Getting Started guide to install @codefast/ui, or browse the full component gallery.