This page as markdown: /menubar.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt

Menubar

Status: stable

An application's row of menus — File, Edit, View — over Base UI's Menubar. Each menu is an ordinary Sable Menu with a MenubarTrigger as its title; the bar joins them into one tab stop with ←/→ between titles, and once one menu is open, pointing at a neighbour opens it.

Keywords: menubar, menu bar, app menu, file menu, edit menu, application menu, desktop menu

Usage

Use Menubar for a tool or editor whose commands are too many for a toolbar and belong under named menus (File, Edit, View, Help). Use Toolbar for a row of direct actions, a single Menu or OverflowMenu for one set of options, and NavigationMenu-style links for site navigation.

Best practices

Anatomy

Part Required Description
Menubar yes The bar: role=menubar, one tab stop, arrow keys between titles.
Menu yes One per title; the ordinary Menu root.
MenubarTrigger yes The title in the bar that opens its menu.
MenuContent yes The menu's popup, with MenuItem / MenuSubmenu / MenuCheckboxItem rows inside.

Subcomponents

Name Type Description
MenubarTrigger Base UI Menu.Trigger props + className A menu's title in the bar. A small ghost Button in the control type tier, held in the accent wash while its menu is open (sable-open:), so the reader sees which title the popup belongs to.

Props

Name Type Default Description
orientation "horizontal" | "vertical" "horizontal" The bar's axis. Arrow keys follow it: ←/→ along a horizontal bar, ↑/↓ down a vertical one.
loopFocus boolean true Wrap from the last title back to the first with the arrow keys.
modal boolean true While a menu is open, block pointer interaction outside it and lock page scroll, like a lone Menu.
disabled boolean false Disable every menu in the bar.
className string — Layout classes for the bar. Titles take their look from MenubarTrigger.

Tokens used

accent, accent-foreground, foreground, ring

Accessibility

Related

Examples

Editor menus

import { Menu, Menubar, MenubarTrigger, MenuContent, MenuItem, MenuSeparator } from "@sableui/react"

<Menubar aria-label="Editor">
	<Menu>
		<MenubarTrigger>File</MenubarTrigger>
		<MenuContent>
			<MenuItem shortcut="Ctrl N">New</MenuItem>
			<MenuItem shortcut="Ctrl O">Open…</MenuItem>
			<MenuSeparator />
			<MenuItem shortcut="Ctrl S">Save</MenuItem>
		</MenuContent>
	</Menu>
	<Menu>
		<MenubarTrigger>Edit</MenubarTrigger>
		<MenuContent>
			<MenuItem shortcut="Ctrl Z">Undo</MenuItem>
			<MenuItem shortcut="Ctrl Shift Z">Redo</MenuItem>
		</MenuContent>
	</Menu>
</Menubar>

With a submenu and toggling rows

import { Menu, Menubar, MenubarTrigger, MenuCheckboxItem, MenuContent, MenuRadioGroup, MenuRadioItem, MenuSubmenu, MenuSubmenuTrigger } from "@sableui/react"

<Menubar aria-label="Editor">
	<Menu>
		<MenubarTrigger>View</MenubarTrigger>
		<MenuContent>
			<MenuCheckboxItem checked={ruler} onCheckedChange={setRuler}>Show ruler</MenuCheckboxItem>
			<MenuSubmenu>
				<MenuSubmenuTrigger value={zoom}>Zoom</MenuSubmenuTrigger>
				<MenuContent side="inline-end" align="start" sideOffset={4}>
					<MenuRadioGroup value={zoom} onValueChange={setZoom}>
						<MenuRadioItem value="100%">100%</MenuRadioItem>
						<MenuRadioItem value="Fit">Fit</MenuRadioItem>
					</MenuRadioGroup>
				</MenuContent>
			</MenuSubmenu>
		</MenuContent>
	</Menu>
</Menubar>