Menubar

A Menubar is a horizontal list of menu triggers, typically placed at the top of an application window. Each trigger opens a menu container with items, separators, and even nested submenus. It’s perfect for complex navigation needs where many related actions are categorized.

This component is built on top of React Aria Components, ensuring it is fully accessible, supports keyboard navigation, and works across different screen sizes.

Installation

Install the component using the Tailgrids CLI.

npx @tailgrids/cli add menubar

Anatomy

Import the component parts and combine them to create a structured menu bar.

import {
  Menubar,
  MenubarMenu,
  MenubarTrigger,
  MenubarContent,
  MenubarItem,
  MenubarSeparator,
  MenubarShortcut,
  MenubarSub,
  MenubarSubTrigger,
  MenubarSubContent,
  MenubarGroup,
  MenubarLabel,
  MenubarCheckboxItem,
  MenubarRadioItem
} from "@/components/menubar";

export const MenubarExample = () => (
  <Menubar>
    <MenubarMenu>
      <MenubarTrigger />
      <MenubarContent>
        <MenubarItem />
        <MenubarSeparator />
        <MenubarSub>
          <MenubarSubTrigger />
          <MenubarSubContent />
        </MenubarSub>
      </MenubarContent>
    </MenubarMenu>
  </Menubar>
);

Examples

Basic Menubar

The primary usage involving multiple menus with simple items and separators.

With Submenus

Demonstrates nested navigation using MenubarSub, MenubarSubTrigger, and MenubarSubContent.

Checkbox and Radio Items

Use MenubarCheckboxItem and MenubarRadioItem for toggleable settings or single-choice options within groups.

With Shortcuts

Display keyboard shortcuts using the MenubarShortcut component for a more professional desktop-like feel.

API Reference

The root container for the menu bar.

PropTypeDefaultDescription
loopFocusbooleantrueWhether to loop keyboard focus back to the first item when the end of the list is reached.
modalbooleantrueWhether the menubar is modal.
disabledbooleanfalseWhether the whole menubar is disabled.
orientation'horizontal' | 'vertical''horizontal'The orientation of the menubar.
classNamestring-Additional CSS classes.
childrenReact.ReactNode-MenubarMenu elements.

Wraps a trigger and its corresponding dropdown content.

PropTypeDefaultDescription
defaultOpenbooleanfalseWhether the menu is initially open.
openboolean-Whether the menu is currently open (controlled mode).
onOpenChangefunction-Event handler called when the menu is opened or closed.
highlightItemOnHoverbooleantrueWhether moving the pointer over items should highlight them.
closeParentOnEscbooleanfalseWhen in a submenu, determines whether pressing Escape closes the entire menu or only the current child menu.
loopFocusbooleantrueWhether to loop focus back to the first item when using arrow keys.
modalbooleantrueDetermines if the menu enters a modal state when open.

The button that opens the menu.

PropTypeDefaultDescription
disabledbooleanfalseWhether the trigger should ignore user interaction.
openOnHoverboolean-Whether the menu should also open when the trigger is hovered.
delaynumber100How long (ms) to wait before the menu may be opened on hover.
closeDelaynumber0How long (ms) to wait before closing the menu opened on hover.
classNamestring-Additional CSS classes.
Data AttributeValuesDescription
data-popup-open-Present when the associated menu is open.
data-pressed-Present when the trigger is being pressed.

The container for the menu items.

PropTypeDefaultDescription
align'start' | 'center' | 'end''start'How to align the popup relative to the specified side.
alignOffsetnumber0Additional offset along the alignment axis in pixels.
side'top' | 'bottom' | 'left' | 'right' | 'inline-start' | 'inline-end''bottom'Which side of the anchor element to align the popup against.
sideOffsetnumber4Distance between the anchor and the popup in pixels.
classNamestring-Additional CSS classes.
Data AttributeValuesDescription
data-open-Present when the menu is open.
data-closed-Present when the menu is closed.
data-side'top' | 'bottom' | 'left' | 'right' | 'inline-start' | 'inline-end'The side the popup is currently positioned on.
data-align'start' | 'center' | 'end'The alignment of the popup relative to the side.

Represents a single action within a menu.

PropTypeDefaultDescription
labelstring-Overrides the text label for keyboard navigation.
onClickfunction-The click handler for the menu item.
closeOnClickbooleantrueWhether to close the menu when the item is clicked.
disabledbooleanfalseWhether the item should ignore user interaction.
classNamestring-Additional CSS classes.
Data AttributeValuesDescription
data-highlighted-Present when the item is focused or hovered.
data-disabled-Present when the item is disabled.

A menu item that can be toggled on or off.

PropTypeDefaultDescription
checkedboolean-Whether the checkbox item is currently ticked.
defaultCheckedbooleanfalseWhether the checkbox item is initially ticked.
onCheckedChangefunction-Event handler called when the checked state changes.
disabledbooleanfalseWhether the item should ignore user interaction.
classNamestring-Additional CSS classes.
Data AttributeValuesDescription
data-checked-Present when the item is checked.
data-unchecked-Present when the item is unchecked.
data-highlighted-Present when the item is focused or hovered.
data-disabled-Present when the item is disabled.

An item for a single selection within a radio group.

PropTypeDefaultDescription
valueany-Required. The value associated with the item.
onClickfunction-The click handler for the item.
disabledbooleanfalseWhether the item should ignore user interaction.
classNamestring-Additional CSS classes.
Data AttributeValuesDescription
data-checked-Present when the item is selected.
data-unchecked-Present when the item is not selected.
data-highlighted-Present when the item is focused or hovered.
data-disabled-Present when the item is disabled.

The root for a nested submenu.

PropTypeDefaultDescription
openboolean-Whether the submenu is currently open.
defaultOpenbooleanfalseWhether the submenu is initially open.
onOpenChangefunction-Event handler called when the submenu is opened or closed.
highlightItemOnHoverbooleantrueWhether moving the pointer over items should highlight them.

A menu item that opens a submenu.

PropTypeDefaultDescription
disabledbooleanfalseWhether the trigger should ignore user interaction.
openOnHoverboolean-Whether the menu should also open when the trigger is hovered.
delaynumber100How long (ms) to wait before the menu may be opened on hover.
classNamestring-Additional CSS classes.
Data AttributeValuesDescription
data-popup-open-Present when the associated submenu is open.
data-highlighted-Present when the trigger is focused or hovered.
data-disabled-Present when the trigger is disabled.

The container for submenu items.

PropTypeDefaultDescription
align'start' | 'center' | 'end''start'How to align the popup relative to the specified side.
sideOffsetnumber4Distance between the anchor and the popup in pixels.
alignOffsetnumber-5Additional offset along the alignment axis in pixels.
side'top' | 'bottom' | 'left' | 'right' | 'inline-start' | 'inline-end''bottom'Which side of the anchor element to align the popup against.
disableAnchorTrackingbooleanfalseWhether to disable the popup from tracking layout shift of its anchor.
classNamestring-Additional CSS classes.
Data AttributeValuesDescription
data-open-Present when the submenu is open.
data-closed-Present when the submenu is closed.
data-side'top' | 'bottom' | 'left' | 'right' | 'inline-start' | 'inline-end'The side the popup is currently positioned on.
data-align'start' | 'center' | 'end'The alignment of the popup relative to the side.

Groups related menu items.

PropTypeDescription
classNamestringAdditional CSS classes
childrenReact.ReactNodeGroup content

Groups related radio items.

PropTypeDefaultDescription
valueany-The controlled value of the selected radio item.
defaultValueany-The uncontrolled value of the initially selected item.
onValueChangefunction-Callback called when the selected value changes.

A horizontal line that separates menu items.

PropTypeDefaultDescription
orientation'horizontal' | 'vertical''horizontal'The orientation of the line.
classNamestring-Additional CSS classes.

Displays a keyboard shortcut for a menu item.

PropTypeDescription
classNamestringAdditional CSS classes
childrenReact.ReactNodeShortcut text

Used to provide a header for a group of menu items.

PropTypeDescription
classNamestringAdditional CSS classes
childrenReact.ReactNodeLabel text

See Base UI Menubar and Menu for more information.

Accessibility

  • Built with Base UI for industry-standard accessible behaviors.
  • Full keyboard support (Arrows, Enter, Escape, Home, End).
  • Focus management for menu triggers and nested submenus.
  • Proper ARIA roles and attributes (role="menubar", role="menu", role="menuitem").
  • Screen reader support for selection states (checked/unchecked) and hierarchies.