Menubar

An accessible horizontal menubar with menus, submenus, and selection items.

Features

  • Horizontal menus
  • Checkbox and radio items
  • Nested submenus
  • Typeahead
  • Managed focus

Installation

npm install @ariaui/menubar

Examples

Horizontal menubar with nested menus plus checkbox and radio items. Arrow keys traverse items and open submenus.

A menubar with nested menus, item variants, and keyboard navigation.

Preview

No preview output yet.

live.tsxReady

Framer Motion

A menubar with the same structure and style animated through Framer Motion and asChild composition.

Preview

No preview output yet.

live.tsxReady

Anatomy

tsx
import * as Menubar from "@ariaui/menubar";

export default function Example() {
  return (
    <Menubar.Root>
      <Menubar.Menu>
        <Menubar.Trigger />
        <Menubar.Content>
          <Menubar.Item />
          <Menubar.Separator />
          <Menubar.CheckboxItem>
            <Menubar.ItemIndicator />
          </Menubar.CheckboxItem>
          <Menubar.RadioGroup>
            <Menubar.Label />
            <Menubar.RadioItem>
              <Menubar.ItemIndicator />
            </Menubar.RadioItem>
          </Menubar.RadioGroup>
          <Menubar.Group>
            <Menubar.Label />
          </Menubar.Group>
          <Menubar.Sub>
            <Menubar.SubTrigger />
            <Menubar.SubContent>
              <Menubar.Item />
            </Menubar.SubContent>
          </Menubar.Sub>
        </Menubar.Content>
      </Menubar.Menu>
    </Menubar.Root>
  );
}

API Reference

Root

Horizontal menubar container. Tracks the currently open menu and provides arrow-key navigation between triggers.

PropTypeDefault
value
string
defaultValue
string
onValueChange
(value: string) => void
loop
booleanfalse
AttributeValues
rolemenubar
data-orientationhorizontal

Trigger

Button that opens its menu on click, Enter, Space, or ArrowDown.

AttributeValues
[data-state]open | closed
aria-haspopupmenu
aria-expandedtrue when the menu is open
aria-controlsID of the Content element

Content

Floating panel containing menu items. Positioned relative to its Trigger and closes on outside click or Escape.

PropTypeDefault
asChild
booleanfalse
loop
booleanfalse
AttributeValues
rolemenu
[data-state]open | closed
[data-side]top | right | bottom | left
[data-align]start | center | end

Item

A selectable command inside a menu.

PropTypeDefault
textValue
string
onSelect
(event: Event) => void
disabled
booleanfalse
AttributeValues
rolemenuitem
[data-active]true when focused/hovered
[data-disabled]present when disabled

CheckboxItem

Menu item with a toggleable checked state.

PropTypeDefault
checked
boolean
defaultChecked
booleanfalse
onCheckedChange
(checked: boolean) => void
AttributeValues
rolemenuitemcheckbox
aria-checkedtrue | false

RadioGroup

Groups RadioItems so only one can be selected at a time.

PropTypeDefault
value
string
defaultValue
string
onValueChange
(value: string) => void
AttributeValues
rolegroup

RadioItem

Selectable item inside a RadioGroup.

PropTypeDefault
value*
string
AttributeValues
rolemenuitemradio
aria-checkedtrue | false

ItemIndicator

Renders only when its parent CheckboxItem or RadioItem is checked.

Group

Groups related menu items. Associates with Label via aria-labelledby when present.

AttributeValues
rolegroup

Label

Non-interactive label used inside a menu to describe a group of items.

Separator

Visual divider between groups of items.

AttributeValues
roleseparator

Sub

Container for a submenu composed of SubTrigger and SubContent.

PropTypeDefault
offset
{ x: number; y: number }{ x: 0, y: 0 }

SubTrigger

Trigger that opens a submenu on hover or ArrowRight.

AttributeValues
[data-state]open | closed
[data-active]true when focused/hovered

SubContent

Submenu panel containing nested items.

PropTypeDefault
asChild
booleanfalse
loop
booleanfalse
AttributeValues
rolemenu
[data-state]open | closed
[data-side]top | right | bottom | left
[data-align]start | center | end

Keyboard

ShortcutAction
/Move focus between menu Triggers along the menubar.
Enter/Space/Open the focused menu and move focus to its first item.
Open the focused menu and move focus to its last item.
/Within an open menu, move focus to the next / previous item.
On a SubTrigger, open the submenu and move focus to its first item.
Inside a submenu, close it and return focus to the SubTrigger.
Home/EndMove focus to the first / last item in the open menu.
Enter/SpaceActivate the focused item. For CheckboxItem / RadioItem, toggles the value.
EscClose the open menu and return focus to its Trigger.
A-Z/0-9Typeahead — move focus to the next item whose text starts with the typed characters.

Accessibility

The Menubar component implements the WAI-ARIA Menubar pattern:

  • Root renders as role="menubar".
  • Trigger exposes aria-haspopup="menu", aria-expanded, and aria-controls.
  • Content and SubContent render as role="menu".
  • Item, CheckboxItem, and RadioItem expose the correct menu item roles and checked state.
  • Focus moves between triggers and menu items with the keyboard, and returns to the trigger when a menu closes.
  • Disabled items expose aria-disabled="true" and cannot be activated.
Previous
Listbox