Menubar
A horizontal bar of menus, like File, Edit and View in a desktop app.
SourceStyles source@monoline/react 0.5.0Markdown for AI toolsstable
- Built on native ARIA (shared positioning)
- 7 parts, named exports
- role="menubar"; arrow keys move between menus and items, Enter or Space opens.
- Escape closes the open menu and returns focus to its trigger.
- Styles in one file:
popover.css
Import
import '@monoline/css';
import {Menubar} from '@monoline/react';
Not installed yet? Pick a route.
Copies the source and its styles into your project.
npx monoline add menubar
Usage
import {Menubar, MenubarContent, MenubarItem, MenubarMenu, MenubarSeparator, MenubarTrigger} from '@monoline/react';
<Menubar aria-label="Application">
<MenubarMenu><MenubarTrigger>File</MenubarTrigger><MenubarContent><MenubarItem>New file</MenubarItem><MenubarItem>Open</MenubarItem><MenubarSeparator /><MenubarItem>Quit</MenubarItem></MenubarContent></MenubarMenu>
<MenubarMenu><MenubarTrigger>Edit</MenubarTrigger><MenubarContent><MenubarItem>Undo</MenubarItem><MenubarItem>Redo</MenubarItem></MenubarContent></MenubarMenu>
</Menubar>
Anatomy
Import the parts you need and nest them like this.
import {Menubar, MenubarMenu, MenubarTrigger, MenubarContent, MenubarItem, MenubarLabel, MenubarSeparator} from '@monoline/react';
<Menubar>
<MenubarMenu />
<MenubarTrigger />
<MenubarContent />
<MenubarItem />
<MenubarLabel />
<MenubarSeparator />
</Menubar>
Examples
App menu
Props
MenubarItemProps
| Prop | Type | Default | Description |
|---|---|---|---|
tone | "danger" | "default" | 'default' | `danger` highlights in the danger colour. |
Data Attributes
State is exposed through attributes. Style it with these selectors, not with class toggles.
| Attribute | Stylesheet |
|---|---|
[data-disabled] | popover.css |
[data-highlighted] | popover.css |
[data-variant="danger"] | popover.css |
[data-highlighted] | menubar.css |
[data-state="open"] | menubar.css |
CSS classes
| Class | Stylesheet |
|---|---|
.menu-content | popover.css |
.menu-indicator | popover.css |
.menu-item | popover.css |
.menu-item-check | popover.css |
.menu-label | popover.css |
.popover | popover.css |
.danger | 17-dropdown-menu.css |
.dropdown | 17-dropdown-menu.css |
.menu | 17-dropdown-menu.css |
.menu-end | 17-dropdown-menu.css |
.menu-item | 17-dropdown-menu.css |
.menu-sep | 17-dropdown-menu.css |
.menubar | menubar.css |
.menubar-trigger | menubar.css |
Customization
Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.
app.css
.menu-content {
border-color: var(--accent);
}
.menu-content[data-disabled] {
background: var(--wash);
}
Accessibility
- role="menubar"; arrow keys move between menus and items, Enter or Space opens.
- Escape closes the open menu and returns focus to its trigger.
Keyboard
| Keys | Action |
|---|---|
| Arrow keys | Move between menus and items |
| Enter / Space | Opens |
| Escape | Closes the open menu and returns focus to its trigger |