Skip to main content

Menubar

StorybookView in Storybook

Explore interactive examples and all component variations in our Storybook.

The Menubar component renders a horizontal application-style menu bar — the kind found at the top of desktop applications. Built on Radix UI primitives, it supports keyboard navigation, submenus, checkboxes, radio groups, and keyboard shortcuts.

Basic Usage

Full Text Editor

A realistic text-editor menubar with File, Edit, View, and Help menus, including submenus, checkboxes, and a radio group.

With Checkboxes

A stateful View menu demonstrating toggled MenubarCheckboxItem entries controlled with useState.

With Radio Group

A stateful example where a MenubarRadioGroup controls the active theme selection.

Properties

PropertyTypeDescription
classNamestringAdditional CSS classes. Renders as a horizontal flex bar with border and shadow.
childrenReact.ReactNodeOne or more MenubarMenu components.
PropertyTypeDescription
valuestringA unique value for the menu (used when controlling the open menu externally).
childrenReact.ReactNodeA MenubarTrigger + MenubarContent pair.
PropertyTypeDescription
classNamestringAdditional CSS classes for the trigger tab.
childrenReact.ReactNodeThe label text displayed in the menu bar.
PropertyTypeDescription
classNamestringAdditional CSS classes for the dropdown panel.
align"start" | "center" | "end"Alignment against the trigger. Default: "start".
alignOffsetnumberOffset along the alignment axis. Default: -4.
sideOffsetnumberDistance from the trigger. Default: 8.
PropertyTypeDescription
insetbooleanAdds left padding to align with items that have icons.
disabledbooleanWhen true, prevents interaction with the item.
onSelect(event: Event) => voidEvent handler called when the item is selected.
classNamestringAdditional CSS classes for custom styling.
PropertyTypeDescription
checkedboolean | "indeterminate"The controlled checked state of the item.
onCheckedChange(checked: boolean) => voidEvent handler called when the checked state changes.
disabledbooleanWhen true, prevents interaction with the item.
classNamestringAdditional CSS classes for custom styling.
PropertyTypeDescription
valuestringThe controlled value of the selected radio item.
onValueChange(value: string) => voidEvent handler called when the selected value changes.
PropertyTypeDescription
valuestringThe unique value of the radio item.
disabledbooleanWhen true, prevents interaction with the item.
classNamestringAdditional CSS classes for custom styling.
PropertyTypeDescription
insetbooleanAdds left padding to align the label with inset menu items.
classNamestringAdditional CSS classes for custom styling.
PropertyTypeDescription
classNamestringAdditional CSS classes for custom styling.
PropertyTypeDescription
classNamestringAdditional CSS classes for custom styling.
childrenReact.ReactNodeThe shortcut text displayed on the right side of a menu item (e.g., ⌘S).
PropertyTypeDescription
insetbooleanAdds left padding for alignment with items that have icons.
classNamestringAdditional CSS classes for custom styling.
childrenReact.ReactNodeThe label for the submenu trigger. A chevron icon is appended automatically.

Accessibility

The Menubar component includes comprehensive accessibility features:

  • Keyboard Navigation - Arrow keys move between menus and items; Enter opens a menu or selects an item; Escape closes the open menu
  • Focus Management - Focus moves into the open menu and returns to the trigger on close
  • Screen Reader Support - ARIA menubar, menu, menuitem, menuitemcheckbox, and menuitemradio roles
  • Type-ahead - Typing a character jumps to the first matching item in the open menu
  • Roving Tabindex - Only the active trigger is focusable in the bar at any time

Common Use Cases

The Menubar component is ideal for:

  • Text and Code Editors - File, Edit, View, and Help menus with shortcuts
  • Design Tools - Layer actions, view toggles, grid and guide options
  • Admin Dashboards - Navigation structure that mirrors a desktop application
  • Data Tools - Import, export, filter, and view configuration menus
  • Settings Pages - Organized preference panels with checkboxes and radio groups

Best Practices

  1. Follow desktop conventions - Users expect menu bar labels like File, Edit, View, Help
  2. Group logically - Use MenubarSeparator and MenubarLabel to organize related items
  3. Include keyboard shortcuts - Add MenubarShortcut for frequently used actions
  4. Limit top-level menus - Keep the bar readable; avoid more than 6-7 top-level triggers
  5. Disable unavailable items - Use disabled rather than hiding items to maintain layout stability
  6. Use submenus sparingly - One level of nesting is usually sufficient; avoid deeper hierarchies
  7. Keep trigger labels short - Single words like "File" or "View" work best in the bar