Toolbar
A row of controls that act on one thing: a text, the selected rows, a chart. It is one stop for the Tab key; the arrow keys move inside it.
import { Toolbar, ToolbarGroup, ToolbarSeparator, ToolbarSpacer, ToolbarSkeleton } from '@sypnia/ui/react'
Formatting a text
Groups of icon buttons, a separator, and the history pushed to the end. icons keeps it on one row on phones.
Code
import { IconButton, Toolbar, ToolbarGroup, ToolbarSeparator, ToolbarSpacer, Button } from '@sypnia/ui/react';
export default function Editor() {
return (
<Toolbar label="Text formatting" bar icons>
<ToolbarGroup label="Style" icons>
<IconButton icon="bold" label="Bold" />
<IconButton icon="italic" label="Italic" />
<IconButton icon="underline" label="Underline" />
</ToolbarGroup>
<ToolbarSeparator />
<ToolbarGroup label="Paragraph" icons>
<IconButton icon="list" label="List" />
<IconButton icon="list-ordered" label="Numbered list" />
<IconButton icon="quote" label="Quote" />
</ToolbarGroup>
<ToolbarSpacer />
<IconButton icon="undo" label="Undo" />
<IconButton icon="redo" label="Redo" />
</Toolbar>
);
} Acting on selected rows
Text buttons sit two by two on phones.
Code
import { Button, Toolbar, ToolbarGroup } from '@sypnia/ui/react';
// Text buttons sit two by two on phones.
export default function Rows() {
return (
<Toolbar label="Selected rows" start>
<ToolbarGroup label="Change">
<Button size="sm" icon="export">Export</Button>
<Button size="sm" icon="archive">Archive</Button>
<Button size="sm" icon="tag">Add a tag</Button>
<Button size="sm" variant="danger-quiet" icon="trash">Delete</Button>
</ToolbarGroup>
</Toolbar>
);
} Skeleton
ToolbarSkeleton has the shape of the bar that is coming: as many control-sized bars as it will have controls.
Code
import { Toolbar, ToolbarGroup, ToolbarSkeleton, Button } from '@sypnia/ui/react';
export default function Loading() {
return (
<div className="sy-stack" style={{ '--gap': 'var(--s-3)' } as React.CSSProperties}>
<Toolbar label="Filters" bar start><ToolbarGroup><Button size="sm">Status</Button><Button size="sm">Owner</Button><Button size="sm">Date</Button></ToolbarGroup></Toolbar>
<ToolbarSkeleton items={3} bar />
</div>
);
} When to use it
Use it when
- Several controls act on the same thing and belong together.
- A bar above an editor, a canvas or a table.
Do not use it when
- Two or three buttons that close a form: that is Actions.
- Links to other pages: that is navigation, not a toolbar.
For everyone
- One Tab stop for the whole bar; Left and Right move between controls, Home and End go to the ends (WAI-ARIA toolbar).
- Its name says what the tools act on: «Text formatting», «Selected rows».
- Every icon button has a name and a hint.
Props
| Toolbar | Type | Default |
|---|---|---|
labelrequiredWhat the tools act on: «Text formatting», «Selected rows». | string | |
barA bordered bar instead of a bare row. | boolean | |
className | string | |
iconsOnly icon buttons: it stays one row on phones (text buttons sit two by two). | boolean | |
startKeep the groups at the start instead of spreading them. | boolean |
| ToolbarGroup | Type | Default |
|---|---|---|
icons | boolean | |
label | string |
| ToolbarSkeleton | Type | Default |
|---|---|---|
bar | boolean | |
items | number | 3 |