Skip to content

Menubar

The strip of words at the top of an application (File, Edit, View), each of which opens a menu. Once one is open, moving along the strip walks through the others rather than closing the one you left.

tsx
import { Menubar, MenubarMenu, MenuItem, MenuSeparator } from 'neba';

<Menubar>
  <MenubarMenu label="File">
    <MenuItem shortcut="⌘N">New file</MenuItem>
    <MenuSeparator />
    <MenuItem>Open…</MenuItem>
  </MenubarMenu>
</Menubar>;

Props

PropTypeDefaultDescription
sizeshared'xs' | 'sm' | 'md' | 'lg' | 'xl''md'The height and type scale of the words. Its own ladder, one rung below the control heights at every step
colorshared'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info''primary'The role the word of an open menu carries
densityshared'default' | 'compact''default'The horizontal padding of the words and nothing else
orientationshared'horizontal' | 'vertical''horizontal'Which way the bar runs. The arrow keys follow it
modalbooleantrueWhether an open menu takes the page away
loopFocusbooleantrueWhether the arrow keys wrap around at the ends of the bar
disabledbooleanfalseDisables every menu on the bar at once
childrenReactNodeThe menus

Every native <div> attribute passes through, apart from color.

It draws no surface of its own. A menu bar sits on something (a Toolbar, a WindowPane's title bar, a Header), and a sheet under a strip that is already on a sheet is two sheets.

PropTypeDefaultDescription
label * ReactNodeThe word on the bar
startIconReactNodeContent before the label. Sized in em, so it tracks it
disabledbooleanfalseUnavailable. The word stays on the bar and opens nothing
childrenReactNodeThe rows, written exactly as they are inside a Menu

The rows are the same MenuItem, MenuSeparator, MenuGroup, MenuCheckboxItem, MenuRadioGroup and MenuSubmenu a Menu takes, because it is the same menu. size, color and density belong to the bar and are not repeated here.

Examples

Nested and checkable rows

Everything a Menu can hold, a menu on the bar can hold: submenus, groups, checkboxes and radio rows.

size

Its own ladder, one rung below the control heights at every step: a menu bar is a strip of words rather than a row of buttons, and it usually sits inside something that already has a height.

orientation

vertical stacks the words instead, and the arrow keys follow.

On a window

Accessibility

  • Renders role="menubar" with each word a menuitem that owns a menu.
  • The whole bar is one tab stop; the arrow keys move between the words and into the rows, and typeahead works in both.
  • Give the bar an aria-label where a page holds more than one.

Released under the MIT License