Menubar
An always-visible row of menus along the top of a workspace, holding the commands that act on the whole screen rather than on one selected thing.
Menubar
Three peer menus on one strip. Open any of them and Left/Right walks to its neighbours, hovering another opens it, and typeahead searches the menu you are in ā the single roving focus is what a row of separate dropdowns cannot give you.
Usage
import {
Menubar,
MenubarCheckboxItem,
MenubarContent,
MenubarGroup,
MenubarItem,
MenubarLabel,
MenubarMenu,
MenubarPortal,
MenubarRadioGroup,
MenubarRadioItem,
MenubarSeparator,
MenubarShortcut,
MenubarSub,
MenubarSubContent,
MenubarSubTrigger,
MenubarTrigger,
} from '@oceanic-hub/brand-system'<Menubar>
<MenubarMenu>
<MenubarTrigger>ā¦</MenubarTrigger>
<MenubarContent>
<MenubarItem>
<MenubarShortcut>ā¦</MenubarShortcut>
</MenubarItem>
<MenubarSeparator>ā¦</MenubarSeparator>
</MenubarContent>
</MenubarMenu>
</Menubar>Composition
Use the following composition to build a Menubar:
Menubar
āāā MenubarMenu Ć3
āāā MenubarTrigger
āāā MenubarContent
āāā MenubarItem Ć6
ā āāā MenubarShortcut
āāā MenubarSeparator Ć2
āāā MenubarCheckboxItem Ć3
āāā MenubarLabel Ć2
āāā MenubarRadioGroup Ć2
ā āāā MenubarRadioItem Ć3
āāā MenubarSub Ć2
āāā MenubarSubTrigger
āāā MenubarSubContent
āāā MenubarItem Ć3Reach for it when one long-lived surface ā an editor, a canvas, a run console ā is worked all day and the same command set applies the whole time. A menubar buys permanent discoverability and pays for it in permanent vertical space, so it only earns its place on a screen a reader stays on. A page they pass through wants neither.
It is one of three ways to open the same menu, and the difference is what summons it.
DropdownMenu is summoned by a control and belongs to that control. ContextMenu is summoned by
a right-click and belongs to the thing under the pointer ā a row, a card, a selection. A menubar is
summoned by nothing: it is already there, and so its commands must be ones that are always
applicable. "Delete row" does not belong in a menubar; "New run" does. All three draw as one
object, and since @OCE-1870 that is true of the rendered pixels and not only of the intent: this
panel used to sit at min-w-48 against the other two at min-w-40, and to carry no motion
where a dropdown popped. It is min-w-40 now, and it pops.
The property that makes it a bar rather than three dropdowns in a row: one roving focus across
the whole strip. Open any menu and Left/Right walks to its neighbours, hovering another opens it,
and typeahead searches the menu you are in. Three separate DropdownMenus look the same and give
none of that, so a menubar assembled out of them is a menubar only to the eye.
Whether the arrows wrap at the ends of the bar is a product decision and stays yours; so does keeping the open menu in your own state when something outside the bar has to close it.
A menubar is horizontal by construction. Radix's is, ours is, and there is no orientation to
flip: a vertical stack of menus is a navigation rail ā WorkspaceNav when it is a flat list of
destinations, Sidebar when the rows carry submenus and actions of their own. The refusal is
pinned in menubar.contract.test-d.ts so a bar and a rail cannot blur into each other. There is
no MenubarArrow either: an arrow is a second elevation signal on a surface whose elevation is
already a hairline border.
RTL is not supported. Upstream ships an RTL menubar demo; we do not, because nothing in this
package has ever been laid out or measured right-to-left. The refusal is written down in
pairings.json under direction ā advertising support we have not measured is the failure mode
this repo refuses everywhere else.
Checkbox items
Independent toggles that change what the screen shows, kept where the reader already is. Reach for one when the switch is flipped every few minutes; a settings dialog is the wrong home for something used that often. Selecting an item closes the menu by default, so these call preventDefault() on select to hold it open across three flips, and inset keeps the plain item at the foot on the same left edge as the ticks above it.
Radio items
One choice out of a short exclusive set, with the live one already marked. Reach for it over checkboxes when picking a second option has to un-pick the first ā sort order, density, theme. MenubarLabel names the axis, which is the only thing that tells a reader why these three cannot all be on at once.
Submenus
Nest a branch under MenubarSub when a command needs a target it cannot fit on one line ā "Export as", "Send to" ā so the parent menu stays a list of verbs. One level is the budget: a second is a reader navigating a tree with the mouse, and that wants a dialog instead.
With icons
An icon is worth it when a returning reader aims at the shape rather than reading the word. Either every item in a menu takes one or none of them do ā a half-iconed menu leaves its labels on two different left edges. MenubarItem already carries the gap, so the icon needs no spacing class of its own.
API Reference
See the Menubar API page for every prop of every part, with types, defaults and the contract that pins them.