Components / Structure
Toolbar
Groups related controls into one named bar with a single Tab stop, following the WAI-ARIA toolbar pattern. Arrow keys move between the controls. For one standalone action, use Button.
When to useLink to "When to use"
- Three or more related controls in a row: editor actions, tree actions, table headers, popup chrome.
- Mixed controls that should share one Tab stop (buttons, a SegmentedControl, a search field).
Use something else when:
- you have one or two actions: place Buttons directly
- the controls are page navigation: links in a navigation landmark
UsageLink to "Usage"
import { IconButton, SearchField, SegmentedControl, Toolbar } from "@arshad-shah/cynosure";
import { code, edit, tree } from "@arshad-shah/cynosure/icons";
<Toolbar label="Document actions">
<IconButton icon={edit} label="Edit" />
<SegmentedControl
label="View"
defaultValue="tree"
options={[
{ value: "tree", label: "Tree", icon: tree },
{ value: "raw", label: "Raw", icon: code },
]}
/>
<SearchField label="Search" labelHidden />
</Toolbar>label is required: a toolbar must have an accessible name.
Fields in a toolbarLink to "Fields in a toolbar"
Text fields keep their own arrow, Home and End keys, so typing still works. Fields sit level with the buttons.
Vertical toolbarsLink to "Vertical toolbars"
Set orientation="vertical" to use Up and Down instead of Left and Right.
loop (default true) wraps from the last control to the first. Set loop={false} to stop at the ends.
PropsLink to "Props"
| Prop | What it does | Type | Default |
|---|---|---|---|
labelRequired | Accessible name (required: a toolbar must be named). | string | |
orientation | Direction of the toolbar: Left/Right move between controls, or Up/Down when vertical. Default "horizontal". | "horizontal" | "vertical" | "horizontal" |
loop | Arrow keys wrap from the last item to the first. | boolean | |
className | Added to the root element, for layout. | string | |
style | Layout only. | CSSProperties | |
children | Buttons, IconButtons, SegmentedControls, fields. | ReactNode | |
data-testid | Test id, set on the toolbar element. | string |
Generated from the type definitions in @arshad-shah/cynosure 0.5.0.
Behaviour and accessibilityLink to "Behaviour and accessibility"
| Input | Result |
|---|---|
| Tab | Enters the toolbar on one control, then leaves it. Returning lands on the last focused control |
| Left and Right arrows | Move focus (flipped in right-to-left layouts) |
| Up and Down arrows | Move focus in a vertical toolbar |
| Home, End | Jump to the first or last control |
- Disabled controls are skipped.
- Radios inside (SegmentedControl) are separate stops: arrows move focus and Space selects, as in the APG toolbar pattern.
- Late additions: controls added after render join the group automatically.
- Role:
role="toolbar"witharia-labelandaria-orientation.
ThemingLink to "Theming"
Tokens: --cy-toolbar-gap and --cy-toolbar-padding.
createTheme({ components: { toolbar: { gap: "4px", padding: "6px" } } });className and style are for layout only.
RelatedLink to "Related"
These examples run Cynosure 0.5.0 (commit 50ce30b), the version on npm.