Skip to content

Now in the official shadcn registry directory.

Start free

Menubar

A desktop-style menu bar with danger items, checkbox items, radio groups, submenus and shortcuts.

navigationoverlay
A free styled version is available

Installation

Run the following command

npx shadcn@latest add @ai2/menubar

Dependencies, the @ai2/tokens theme and the component file are installed together.

Usage

TS
import {
  Menubar,
  MenubarContent,
  MenubarItem,
  MenubarMenu,
  MenubarSeparator,
  MenubarShortcut,
  MenubarTrigger,
} from "@/components/ui/menubar"

<Menubar>
  <MenubarMenu>
    <MenubarTrigger>File</MenubarTrigger>
    <MenubarContent>
      <MenubarItem>
        New file <MenubarShortcut>Cmd N</MenubarShortcut>
      </MenubarItem>
      <MenubarSeparator />
      <MenubarItem variant="danger">Delete</MenubarItem>
    </MenubarContent>
  </MenubarMenu>
</Menubar>

Wrap the whole row in Menubar, then add one MenubarMenu per top-level entry. Once one menu is open, the pointer and arrow keys move across the bar.

Examples

Multiple menus

A File / Edit / View bar. Open one menu, then move across the row with the pointer or the arrow keys to switch menus. The Edit menu closes with a variant="danger" item.

Checkbox and radio items

Checkbox items toggle independently with checked and onCheckedChange; the radio group gives an exclusive choice via value and onValueChange.

Props

All parts forward their radix Menubar props: onSelect and disabled on items, value / onValueChange on the root for controlled open state. The ai2-specific props:

PropTypeDefaultDescription
variant"default" | "danger""default"danger colors the item (and its icons) with the danger tone for destructive actions.
insetboolean-Adds left padding so plain items align with checkbox and radio items. Also available on MenubarLabel and MenubarSubTrigger.
PropTypeDefaultDescription
align"start" | "center" | "end""start"Alignment of the menu against its trigger.
alignOffsetnumber-4Offset in pixels along the alignment axis.
sideOffsetnumber8Distance in pixels between the trigger and the menu.

ai2 Menubar: a desktop application menu bar for React

The ai2 Menubar is a shadcn-compatible menu bar component for React, built on the radix-ui Menubar primitive and styled with Tailwind CSS v4. It is the horizontal File / Edit / View bar you know from desktop apps: a row of top-level triggers, each opening a menu that covers the whole vocabulary, plain actions, a danger variant for destructive items, checkbox items, radio groups, nested submenus, labels, separators and shortcut hints.

Because it ships through the shadcn registry format, you install it with one CLI command, an MCP agent, or a copy-paste, and the source lands in your own project. You own the file; there is no runtime dependency on ai2 itself. The live example above is the exact component you get.

What is the ai2 Menubar?

It is a composition around Menubar as the container, with one MenubarMenu per top-level entry, each holding a MenubarTrigger and a MenubarContent. Inside, the item set is the same one you get from the ai2 Dropdown Menu: MenubarItem, MenubarCheckboxItem, MenubarRadioGroup, label, separator, shortcut and the MenubarSub trio for nesting.

On top of the radix API, items add two ai2 props: variant, where danger colors the item and its icons with the danger tone, and inset, which aligns plain items with checkbox and radio rows. Once one menu is open, moving the pointer across the bar or pressing the arrow keys switches to the neighbouring menu, exactly like a native menu bar.

Why use it

  • Roving focus across the bar: The radix-ui Menubar primitive coordinates the whole row: open one menu and the next trigger opens on hover or with the arrow keys, so the bar behaves like a desktop menu instead of a set of unrelated dropdowns.
  • Accessible by construction: Menu roles, typeahead, focus management and dismissal come from radix: arrow keys move within and between menus, Enter selects, Escape closes and focus returns to the trigger.
  • Danger items built in: variant="danger" styles destructive actions like Delete with the danger token, including their icons and a soft danger highlight on focus, no custom classes needed.
  • Stateful items included: Checkbox items with check indicators and exclusive radio groups with dot indicators ship in the same file, so appearance toggles and layout pickers need no extra components.
  • Agent-readable metadata: The registry item describes its parts and intended use in plain words, so an MCP agent can find, inspect and install it without guessing.

Features

  • shadcn registry install: One command adds the component, its dependencies and the @ai2/tokens theme to your project.
  • Styled container: The Menubar root ships a bordered, rounded bar with a subtle shadow, so the row reads as one surface without extra layout work.
  • Tuned content placement: MenubarContent defaults to align start with an eight-pixel side offset and a small negative align offset, so menus sit flush under their trigger.
  • Labels, separators and shortcuts: MenubarLabel titles a section, MenubarSeparator splits groups, and MenubarShortcut right-aligns a keyboard hint inside any item.
  • Submenus included: MenubarSub with MenubarSubTrigger and MenubarSubContent gives hover and keyboard-openable nested menus with a chevron indicator.
  • Data attributes for styling: Every part exposes data-slot, items expose data-variant, and radix adds data-state and data-disabled, so any state is targetable from CSS.

Production tips

  • Keep the top row short: Four to six top-level menus is the desktop convention. If you need more, the surface probably wants a sidebar or a command palette rather than a wider bar.
  • Group with separators, not depth: Split related actions inside one menu with a MenubarSeparator before you reach for a submenu. Flat menus are faster to scan than nested ones.
  • Put danger items last: Separate destructive actions with a MenubarSeparator and keep them at the bottom with variant="danger", so muscle memory never lands on Delete.
  • Menus act, they do not hold forms: Use onSelect for actions and radio items for view preferences. For entering values, a dialog or a dedicated form is the right place, not the menu bar.
  • This is a desktop pattern: A menu bar suits editor-style and dashboard apps on wide screens. On small screens, collapse it into a single dropdown or a navigation drawer instead.

Works with the rest of ai2

A menu bar sits at the top of an app shell, so it pairs with a ai2 Button toolbar and ai2 Kbd caps inside its shortcut hints. For a single button-triggered menu with the same item vocabulary, use the ai2 Dropdown Menu, and for a right-click menu use the ai2 Context Menu.

A danger item usually leads to a confirmation, so pair it with the ai2 Dialog. All of these menus share one token source and the same popover surface styling, so a mixed app stays visually consistent.

FAQs

Get new components in your inbox

Component drops, new themes and release notes. No spam, and you can unsubscribe from any email.

© 2026 ai2 design system · MIT licensed · Built with its own components