Navigation
Toolbar
Free2.6 KB gzippedA row (or column) of controls that is one Tab stop, with arrow keys between controls.
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Tab, Shift+Tab, Arrow Right and 5 more · Full report
Import
import { Toolbar } from "@vjdesigns/vjdesigns-ui";
Importing only Toolbar adds about 2.6 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.
Examples
Basic
The whole toolbar is one Tab stop. Arrow keys move between its controls, and Home and End jump to the first and last. A ToggleGroup inside joins the toolbar's arrow keys.
import {
IconButton,
LinkIcon,
ToggleGroup,
Toolbar,
} from "@vjdesigns/vjdesigns-ui";
export function Basic() {
return (
<Toolbar aria-label="Text formatting">
<ToggleGroup type="multiple" aria-label="Text style" variant="ghost" tone="neutral" size="sm">
<ToggleGroup.Item value="bold">Bold</ToggleGroup.Item>
<ToggleGroup.Item value="italic">Italic</ToggleGroup.Item>
<ToggleGroup.Item value="underline">Underline</ToggleGroup.Item>
</ToggleGroup>
<Toolbar.Separator />
<ToggleGroup type="single" aria-label="Alignment" variant="ghost" tone="neutral" size="sm" defaultValue="start" required>
<ToggleGroup.Item value="start">Left</ToggleGroup.Item>
<ToggleGroup.Item value="center">Center</ToggleGroup.Item>
<ToggleGroup.Item value="end">Right</ToggleGroup.Item>
</ToggleGroup>
<Toolbar.Separator />
<IconButton aria-label="Insert link" variant="ghost" tone="neutral" size="sm">
<LinkIcon />
</IconButton>
</Toolbar>
);
}
Variants
variant="plain" drops the border and background. orientation="vertical" stacks the controls and uses the Up and Down arrows.
import {
CopyIcon,
EditIcon,
IconButton,
Toolbar,
TrashIcon,
} from "@vjdesigns/vjdesigns-ui";
export function Variants() {
return (
<div style={{ display: "flex", gap: "1.5rem", alignItems: "flex-start", flexWrap: "wrap" }}>
<Toolbar variant="plain" aria-label="Row actions">
<IconButton aria-label="Edit" variant="ghost" tone="neutral" size="sm">
<EditIcon />
</IconButton>
<IconButton aria-label="Copy" variant="ghost" tone="neutral" size="sm">
<CopyIcon />
</IconButton>
<IconButton aria-label="Delete" variant="ghost" tone="danger" size="sm">
<TrashIcon />
</IconButton>
</Toolbar>
<Toolbar orientation="vertical" aria-label="Drawing tools">
<IconButton aria-label="Edit" variant="ghost" tone="neutral" size="sm">
<EditIcon />
</IconButton>
<IconButton aria-label="Copy" variant="ghost" tone="neutral" size="sm">
<CopyIcon />
</IconButton>
<Toolbar.Separator />
<IconButton aria-label="Delete" variant="ghost" tone="danger" size="sm">
<TrashIcon />
</IconButton>
</Toolbar>
</div>
);
}
With input
A text field keeps its own caret keys: the arrow keys, Home and End edit the text. Tab still leaves the toolbar. wrap moves controls onto a new line when there isn't room, keeping each Toolbar.Group together.
import {
FilterIcon,
IconButton,
Input,
MoreHorizontalIcon,
SearchIcon,
Toolbar,
} from "@vjdesigns/vjdesigns-ui";
export function WithInput() {
return (
<div style={{ width: "100%", maxWidth: "34rem" }}>
<Toolbar wrap aria-label="Roster tools">
<Toolbar.Group aria-label="Search">
<Input aria-label="Search players" placeholder="Search players" size="sm" startIcon={<SearchIcon />} />
</Toolbar.Group>
<Toolbar.Group aria-label="Actions">
<IconButton aria-label="Filter" variant="ghost" tone="neutral" size="sm">
<FilterIcon />
</IconButton>
<IconButton aria-label="More actions" variant="ghost" tone="neutral" size="sm">
<MoreHorizontalIcon />
</IconButton>
</Toolbar.Group>
</Toolbar>
</div>
);
}
Disabled and no loop
Disabled controls are skipped. With loop={false}, the arrow keys stop at the first and last control instead of wrapping.
import {
CopyIcon,
EditIcon,
IconButton,
Toolbar,
TrashIcon,
} from "@vjdesigns/vjdesigns-ui";
export function DisabledAndNoLoop() {
return (
<Toolbar loop={false} aria-label="Message actions">
<IconButton aria-label="Edit" variant="ghost" tone="neutral" size="sm">
<EditIcon />
</IconButton>
<IconButton aria-label="Copy" variant="ghost" tone="neutral" size="sm" disabled>
<CopyIcon />
</IconButton>
<IconButton aria-label="Delete" variant="ghost" tone="danger" size="sm">
<TrashIcon />
</IconButton>
</Toolbar>
);
}
Right to left
In right-to-left layouts the toolbar mirrors, and Arrow Left moves to the next control.
import {
IconButton,
LinkIcon,
LocaleProvider,
ToggleGroup,
Toolbar,
} from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
export function RightToLeft() {
return (
<LocaleProvider locale="ar" messages={ar}>
<div dir="rtl">
<Toolbar aria-label="أدوات التنسيق">
<ToggleGroup type="multiple" aria-label="نمط النص" variant="ghost" tone="neutral" size="sm">
<ToggleGroup.Item value="bold">غامق</ToggleGroup.Item>
<ToggleGroup.Item value="italic">مائل</ToggleGroup.Item>
</ToggleGroup>
<Toolbar.Separator />
<IconButton aria-label="إدراج رابط" variant="ghost" tone="neutral" size="sm">
<LinkIcon />
</IconButton>
</Toolbar>
</div>
</LocaleProvider>
);
}
API reference
Toolbar
New in 3.5.1| Prop | Type | Default |
|---|---|---|
orientationDirection of the controls. Also picks the arrow keys: Left/Right when horizontal (following the reading direction), Up/Down when vertical. | "horizontal""vertical" | "horizontal" |
variant
| "plain""surface" | "surface" |
loopArrow keys wrap from the last control to the first, and back. | boolean | true |
wrapLet controls wrap onto more lines when there isn't room (horizontal only). | boolean | false |
childrenThe controls: buttons, toggle groups, links, menus, inputs, | ReactNode | — |
Also accepts native <div> attributes, plus className, style and ref.
Toolbar.Separator
New in 3.5.1A line between groups of controls, drawn across the toolbar's direction (role="separator"). It isn't focusable, and arrow keys skip it.
| Prop | Type | Default |
|---|---|---|
classNameAdditional class for the separator. | string | — |
Toolbar.Group
New in 3.5.1Keeps related controls together (role="group"), so a wrapping toolbar moves them to the next line as one. Its controls stay in the toolbar's arrow-key order.
| Prop | Type | Default |
|---|---|---|
childrenRelated controls. Name the group with | ReactNode | — |
Also accepts native <div> attributes, plus className, style and ref.
See what changed in each version in the Changelog.
Accessibility report
Toolbar targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.
axe-core audit (live)
Checking the examples above…
Lighthouse audit
Light mode
Score 10036 passed · 0 failed · 29 not applicable · 10 to check by hand
Dark mode
Score 10036 passed · 0 failed · 29 not applicable · 10 to check by hand
Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.
Built-in behavior
Keyboard
| Key | Action |
|---|---|
| TabShift+Tab | Moves into the toolbar, on the control used last (or the first), and out of it. The toolbar is one Tab stop. |
| Arrow RightArrow Left | Horizontal: next or previous control, wrapping unless loop={false} (mirrored right to left). Disabled controls are skipped. |
| Arrow DownArrow Up | Vertical: next or previous control. |
| HomeEnd | First or last control. |
In a text field, the arrow keys, Home and End keep editing the text. A ToggleGroup joins the toolbar's arrow keys; widgets with their own arrow keys (radio groups, tabs, SegmentedControl) stay a separate Tab stop.
Roles and states
| Element | Role | States and properties |
|---|---|---|
| Toolbar | toolbar | aria-orientation, aria-label or aria-labelledby (warns in development without one) |
Toolbar.Group | group | aria-label (optional) |
Toolbar.Separator | separator | aria-orientation across the toolbar; not focusable |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck. | 2.1.1 (A), 2.1.2 (A) |
| Focus | Focus moves in a logical order, is always visible, and isn't hidden behind sticky headers. | 2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA) |
| Screen readers | Names, roles and states are announced correctly, and status changes are announced without moving focus. | 1.3.1 (A), 4.1.2 (A), 4.1.3 (AA) |
| Color | Meaning never depends on color alone; your own colors meet contrast in both modes. | 1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA) |
| Zoom and reflow | At 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed. | 1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA) |
| Pointer targets | Click and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap. | 2.5.8 (AA), 2.5.5 (AAA) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |