ComponentsOverlays

Menubar

A row of menus, like the File and View menus of a desktop app. Use it for an editor or tool that has many commands. For one set of actions, use a Dropdown Menu.

Usage

Menubar usageTSX
import {
  Menubar,
  MenubarCheckboxItem,
  MenubarContent,
  MenubarItem,
  MenubarMenu,
  MenubarRadioGroup,
  MenubarRadioItem,
  MenubarSeparator,
  MenubarShortcut,
  MenubarSub,
  MenubarSubContent,
  MenubarSubTrigger,
  MenubarTrigger,
} from "@tulipfarm/sprout/menubar";

<Menubar aria-label="Application menu">
  <MenubarMenu>
    <MenubarTrigger>File</MenubarTrigger>
    <MenubarContent>
      <MenubarItem onClick={newDraft}>
        New draft<MenubarShortcut>⌘ N</MenubarShortcut>
      </MenubarItem>
      <MenubarItem disabled>Print</MenubarItem>
      <MenubarSeparator />
      <MenubarItem variant="destructive" onClick={discard}>Discard draft</MenubarItem>
    </MenubarContent>
  </MenubarMenu>
  <MenubarMenu>
    <MenubarTrigger>View</MenubarTrigger>
    <MenubarContent>
      <MenubarCheckboxItem checked={sidebar} onCheckedChange={setSidebar}>
        Show sidebar
      </MenubarCheckboxItem>
      <MenubarRadioGroup value={density} onValueChange={setDensity}>
        <MenubarRadioItem value="compact">Compact</MenubarRadioItem>
        <MenubarRadioItem value="comfortable">Comfortable</MenubarRadioItem>
      </MenubarRadioGroup>
      <MenubarSub>
        <MenubarSubTrigger>More</MenubarSubTrigger>
        <MenubarSubContent>
          <MenubarItem onClick={zoomIn}>Zoom in</MenubarItem>
        </MenubarSubContent>
      </MenubarSub>
    </MenubarContent>
  </MenubarMenu>
</Menubar>

Variants and states

MenubarItem variant is "default" or "destructive"; destructive items use the danger color and a tinted highlight. disabled items stay readable at half opacity and can still be reached with arrow keys. Checkbox and radio items show a check at the start, so rows without a check use inset to line up with them. Long names in a submenu can truncate with an ellipsis.

Document editor

Icons, labels, inset rows, disabled rows, and a destructive action. Actions only update the message below.

Accessibility

The bar has role="menubar" and is one Tab stop. Arrow Left and Arrow Right move between triggers, Arrow Down or Enter opens a menu, and while a menu is open Arrow Left and Arrow Right move to the next menu. Inside a menu, arrow keys move, typing jumps to a matching item, Arrow Right opens a submenu, and Escape closes the menu and returns focus to its trigger. A focused trigger shows a focus ring.

Menus fade and scale in over 120ms. Motion turns off when reduced motion is requested. In forced-colors mode the open trigger and highlighted item get an outline.

Theme tokens

Menubars use --sprout-surface, --sprout-line, --sprout-hover, --sprout-text, --sprout-muted, --sprout-danger, --sprout-danger-subtle, --sprout-focus, --sprout-shadow-control, --sprout-shadow-overlay, and the panel and control radii. They need no brand color, so they look the same with the neutral and TulipFarm themes in light and dark mode.