Avara UI

Shadcn Menubar

A dependency-free desktop-style menubar (Menubar, MenubarMenu, MenubarTrigger, MenubarContent) with hover-to-swap menu switching and application title-bar support.

Applies to this page's previews only

About Shadcn Menubar

What it is. Menubar (MenubarMenu, MenubarTrigger, MenubarContent, MenubarItem, MenubarSeparator, MenubarShortcut, MenubarLabel) provides a persistent OS-style command bar. There are no checkbox, radio or submenu parts; mark a chosen row with an icon, as the application example does.

How it is built. Plain React Context with no menu library. The bar tracks one open menu by value: click a trigger to open it, then hover the neighbouring triggers to swap. Escape or a mouse press outside closes it. MenubarContent nudges itself back inside the viewport and caps its height.

When to use it. Use Menubar for desktop-style editors, IDEs, and application title bars. For marketing/site navigation, use Navigation Menu; for right-click menus, use Context Menu.

For AI agents

Hand your agent this brief or the Markdown page, not a screenshot.

When to use

  • Persistent desktop-style File / Edit / View command bars in editors or web apps

When not to use

Agent notes

  • Named exports from @/components/custom/blocks/MenubarBlock: Menubar, MenubarMenu, MenubarTrigger, MenubarContent, MenubarItem, MenubarSeparator, MenubarShortcut, MenubarLabel. Nothing else exists, so do not import MenubarCheckboxItem or MenubarSub.
  • Every MenubarMenu requires a unique value prop so context can track the active dropdown. Open state is internal; there is no controlled open prop.
  • MenubarItem is a button that closes the menu after onClick runs.
  • Keyboard support is limited to Tab and Escape. There is no arrow-key navigation and no role="menu" markup.
Install
npx shadcn@latest add https://avaraui.com/r/menubar.json
Registry name
@avara-ui/menubar, through the shadcn MCP server
Index
llms.txt lists every page, or add the agent skill once

Props Reference

ComponentPropTypeDescription
MenubarMenuvaluestring

Required. A unique identifier for the menu column (e.g., "file"). Used by the internal state context to track which dropdown is open.

MenubarContentalign"start" | "center" | "end"

Determines how the dropdown is anchored relative to its trigger button. Defaults to "start".

MenubarIteminsetboolean

Adds extra left-padding to the item, aligning text cleanly when adjacent items use icons.

MenubarItemdisabledboolean

Dims the item, changes the cursor, and completely disables pointer events and click handlers.

MenubarItemonClick(e: React.MouseEvent<HTMLButtonElement>) => void

Fires your custom action. The menu will automatically close after the click.

MenubarLabelinsetboolean

Aligns the label text with inset menu items.

All ComponentsclassNamestring

Every component except MenubarMenu accepts custom Tailwind classes, and the others pass extra HTML attributes to their root element (MenubarSeparator takes only className).

Works with other components

  • Pair Menubar with Resizable panes and Kbd shortcut hints in IDE/editor shells.
  • Use Context Menu for the right-click version of the same actions.
  • Use Navigation Menu for site header links instead of command menus.

Why does each MenubarMenu need a value prop?

Menubar keeps one activeMenu string in React Context, and each MenubarMenu registers its value there. The trigger compares them to know whether to highlight, and the content compares them to know whether to render. Two menus with the same value would open together, so keep each one unique.

What closes a Menubar menu?

Clicking a MenubarItem closes it after your onClick runs. A mouse press anywhere outside the bar closes it, and so does the Escape key. Clicking the open trigger again toggles it shut. Closed menus are unmounted, so MenubarContent renders nothing until its trigger is clicked.

Does Menubar support arrow-key navigation?

No. Triggers and items are native button elements, so Tab and Enter work, and Escape closes the open menu. There is no arrow-key movement, no typeahead, and no role="menubar" or aria-expanded markup. For strict ARIA menu behaviour, use a Radix-based menubar.

How do I fuse a Menubar into a window title bar?

Pass className to Menubar to remove its chrome, for example border-none bg-transparent shadow-none p-0 as the application example does, then place it inside your own header. Each MenubarTrigger is a plain button, so you can restyle triggers with className too.

Does the Menubar dropdown stay on screen near the edge of the window?

Mostly. When a menu opens, MenubarContent measures itself and shifts sideways to stay 8px inside the viewport, then caps its height if it would run past the bottom. align can be start, center or end. It is not portaled, so an ancestor with overflow-hidden will still crop it.

Can I add checkbox, radio or submenu items to Menubar?

Not as built-in parts. The block ships MenubarItem, MenubarLabel, MenubarSeparator and MenubarShortcut only. To show a selected option, hold the state yourself and render a check icon inside a MenubarItem, as the View menu in the application example does for the theme choice.