Mushilu-San UI

Search components

PlaygroundStorybookGitHub
Navigation

Menubar

A horizontal bar of menus, such as File, Edit and View, for desktop-style commands.

Selector: mui-menubar

Import
import { Menubar, MenubarMenu, MenubarTrigger, MenubarContent, MenubarItem, MenubarSeparator } from '@mushilu-san/ui/navigation';
PreviewCode

Loading example…

Overview

Menubar is a role="menubar". Each MenubarTrigger opens a menu of MenubarItem commands. Arrow keys move between triggers and items, and Escape closes the open menu.

Items are role="menuitem" and separators are role="separator". Use MenubarSeparator to group related commands.

When to use

  • Desktop-style apps with many commands grouped by category.
  • Editors and tools where users expect File, Edit and View menus.

When not to use

  • Site navigation with links to pages. Use a navigation menu. Use Navigation menu instead.
  • A single menu of actions on one button. Use a dropdown menu. Use Dropdown menu instead.

Guidelines

Do

  • Keep the top-level titles to one word.
  • Show keyboard shortcuts with the command when there is one.

Don't

  • Do not use a menubar on mobile. Use a bottom navigation or a sheet.

Accessibility

Roles and attributes

ElementRoleNotes
hostmenubararia-label from label, default "Menu bar".
triggermenuitemaria-expanded follows the menu state.
itemmenuitem
separatorseparator

Keyboard

KeysAction
ArrowLeftArrowRightMove between menu titles.
ArrowDownArrowUpMove between items in an open menu.
EnterSpaceActivates the focused item.
EscapeCloses the open menu.
  • Disabled items are skipped by the arrow keys.

API

Menubar

Selector: mui-menubar

NameTypeDefaultDescription
labelstring'Menu bar' Accessible name of the menubar. Default `Menu bar`.

CSS parts

  • ::part(root)

MenubarMenu

Selector: mui-menubar-menu

CSS parts

  • ::part(menu)

MenubarTrigger

Selector: button[muiMenubarTrigger]

CSS parts

  • ::part(trigger)

MenubarContent

Selector: mui-menubar-content

CSS parts

  • ::part(content)

MenubarItem

Selector: [muiMenubarItem]

NameTypeDefaultDescription
disabledbooleanfalse Disables this item. It is skipped by the arrow keys. Accepts attribute presence, e.g. <… disabled>.

CSS parts

  • ::part(item)

MenubarSeparator

Selector: mui-menubar-separator

CSS parts

  • ::part(separator)

Tokens

  • --mui-color-surface-raised
  • --mui-color-border
  • --mui-color-focus-ring
  • --mui-shadow-2