Actions
Toolbar
A row or column of controls with one Tab stop: arrow keys move between buttons, toggles, menus and fields, and the toolbar remembers where you were.
import { Toolbar, ToolbarGroup, ToolbarSeparator, ToolbarOverflowMenu } from '@reactloom/ui';Examples
Text formatting
Groups and separators organise the items; a Menu opens from inside the toolbar.
import { Button, IconButton, Menu, ToggleButton, Toolbar, ToolbarGroup, ToolbarSeparator } from '@reactloom/ui';
import { Bold, ChevronDown, Italic, Link, Underline, Undo2 } from 'lucide-react';
export default function Example() {
return (
<Toolbar aria-label="Formatting">
<IconButton size="sm" icon={<Undo2 />} label="Undo" />
<ToolbarSeparator />
<ToolbarGroup aria-label="Text style">
<ToggleButton size="sm" variant="ghost" aria-label="Bold" startIcon={<Bold />} />
<ToggleButton size="sm" variant="ghost" aria-label="Italic" startIcon={<Italic />} />
<ToggleButton size="sm" variant="ghost" aria-label="Underline" startIcon={<Underline />} />
</ToolbarGroup>
<ToolbarSeparator />
<Menu items={[{ key: 'h1', label: 'Heading 1' }, { key: 'h2', label: 'Heading 2' }, { key: 'p', label: 'Paragraph' }]}>
<Button size="sm" variant="ghost" endIcon={<ChevronDown />}>
Paragraph
</Button>
</Menu>
<IconButton size="sm" icon={<Link />} label="Insert link" />
</Toolbar>
);
}Vertical
Up and down arrows move in a vertical toolbar.
import { IconButton, Toolbar, ToolbarSeparator } from '@reactloom/ui';
import { Circle, Hand, MousePointer2, Pencil, Square, Type } from 'lucide-react';
export default function Example() {
return (
<Toolbar aria-label="Drawing tools" orientation="vertical" style={{ inlineSize: 'fit-content' }}>
<IconButton size="sm" icon={<MousePointer2 />} label="Select" />
<IconButton size="sm" icon={<Hand />} label="Pan" />
<ToolbarSeparator />
<IconButton size="sm" icon={<Square />} label="Rectangle" />
<IconButton size="sm" icon={<Circle />} label="Ellipse" />
<IconButton size="sm" icon={<Pencil />} label="Draw" />
<IconButton size="sm" icon={<Type />} label="Text" />
</Toolbar>
);
}Overflow menu
ToolbarOverflowMenu moves the items that do not fit into a More menu; hidden items leave the arrow-key order, and choosing one in the menu activates the real control. Drag the corner to narrow the box.
import { Button, ToggleButton, Toolbar, ToolbarOverflowMenu, ToolbarSeparator } from '@reactloom/ui';
export default function Example() {
return (
// Resize the window, or narrow this box: the items that do not fit move into “More”.
<div style={{ width: '100%', maxWidth: 360, resize: 'horizontal', overflow: 'hidden', minWidth: 160 }}>
<Toolbar aria-label="Message">
<Button size="sm" variant="ghost">Reply</Button>
<Button size="sm" variant="ghost">Reply all</Button>
<Button size="sm" variant="ghost">Forward</Button>
<ToolbarSeparator />
<Button size="sm" variant="ghost">Archive</Button>
<Button size="sm" variant="ghost">Move</Button>
<ToggleButton size="sm" variant="ghost" defaultPressed>
Flag
</ToggleButton>
<ToolbarOverflowMenu />
</Toolbar>
</div>
);
}API reference
| Prop | Type | Default |
|---|---|---|
aria-label · aria-labelledbyrequiredNames the toolbar. | string | — |
orientationDirection of the arrow keys and the layout. | 'horizontal' | 'vertical' | 'horizontal' |
loopArrow keys wrap from the last item to the first. | boolean | true |
wrapWrap items onto more lines instead of scrolling. | boolean | false |
| Prop | Type | Default |
|---|---|---|
ToolbarGroup aria-labelrole="group" for related items; arrow keys pass through groups. | string | — |
ToolbarSeparatorrole="separator", oriented across the toolbar. | | — |
Customization
Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.
CSS variables
| Variable | Default |
|---|---|
--pl-toolbar-bg | var(--pl-color-bg-surface) |
--pl-toolbar-border-color | var(--pl-color-border-default) |
--pl-toolbar-gap | var(--pl-space-1) |
--pl-toolbar-padding | var(--pl-space-1) |
--pl-toolbar-radius | var(--pl-radius-md) |
State attributes
Target these in your CSS to style states without depending on class names.
| Attribute | Values |
|---|---|
[data-orientation] | horizontal · vertical |
[data-wrap] | present when on |
Theme tokens it reads
--pl-color-bg-surface --pl-color-border-default --pl-radius-md
Accessibility
- Only one item is in the Tab order (roving tabindex); disabled and hidden items are skipped.
- Inside text fields, the arrow keys, Home and End keep editing the text.
- Arrow directions follow the reading direction in right-to-left layouts.
| Key | Action |
|---|---|
| Tab / Shift+Tab | Enter or leave the toolbar (at the last focused item) |
| ← → (↑ ↓ when vertical) | Previous or next item, wrapping |
| Home / End | First or last item |
Usage guidelines
Do
- Group three or more related controls, as in editors and canvases.
- Give icon-only buttons a label and show it in a Tooltip.
Don’t
- Don’t wrap a page’s main navigation in a toolbar.
- Don’t put a single button in a toolbar.