Toolbar
A bar of controls that act on one thing: the text being edited, the chart on screen. The whole bar is one tab stop and the arrow keys move inside it, so a long bar costs the keyboard one Tab. For commands sorted into named menus, use a menubar.
Install
npx shadcn@latest add @thrum-pro/toolbarThis is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
Toolbar: orientation | "horizontal" | "vertical" | Default "horizontal" | The direction of the bar, and which arrow keys move along it. Groups and separators follow it. |
Toolbar: loopFocus | boolean | Default true | Whether the arrow keys wrap from the last control to the first. |
Toolbar: disabled | boolean | Default false | Disables every button and toggle of the bar. Links stay usable. |
Toolbar: sound | boolean | Default true | Play a rising pair of clicks when a toggle is pressed and a falling pair when it is released, if the visitor has sound on. |
Toolbar: className | string | – | Extra classes for the bar. It is as wide as its controls and wraps onto more lines in a narrow container. |
ToolbarButton: variant | "primary" | "secondary" | "outline" | "ghost" | "destructive" | "link" | Default "ghost" | The button variant. Keep ghost for most; primary marks the bar's one main action. |
ToolbarButton: disabled | boolean | Default false | Dimmed, and a press does nothing. It stays reachable with the arrow keys, so a screen reader can find it. |
ToolbarButton: focusableWhenDisabled | boolean | Default true | Set false to take a disabled button out of the arrow-key order as well. |
ToolbarButton: ...props | button props | – | Every other button attribute. A button with only an icon needs an aria-label. |
ToolbarToggle: pressed | boolean | – | Whether a toggle that stands alone is pressed, when the parent holds the state. Use it with onPressedChange. |
ToolbarToggle: defaultPressed | boolean | Default false | Whether a toggle that stands alone starts pressed. |
ToolbarToggle: onPressedChange | (pressed: boolean) => void | – | Called with the new state when the toggle is pressed or released. |
ToolbarToggle: value | string | – | Inside a ToolbarToggleGroup: what the group's value holds while this toggle is pressed. |
ToolbarToggle: variant | "default" | "outline" | Default "default" | default has no frame until it is pressed. outline always shows its border. |
ToolbarToggleGroup: value | readonly string[] | – | The values of the pressed toggles, when the parent holds them. Use it with onValueChange. |
ToolbarToggleGroup: defaultValue | readonly string[] | Default [] | The values pressed at first, when the group holds its own state. |
ToolbarToggleGroup: onValueChange | (value: string[]) => void | – | Called with the new list when a toggle is pressed or released. |
ToolbarToggleGroup: multiple | boolean | Default false | Let several toggles be pressed at once. Without it, pressing one releases the other. |
ToolbarGroup: disabled | boolean | Default false | Disables every button inside the group. |
ToolbarGroup: ...props | div props | – | Buttons that belong together. Name the group with an aria-label. |
ToolbarSeparator | div props | – | A line between groups, drawn across the bar's direction. |
ToolbarLink | anchor props | – | A link on the bar. The arrow keys reach it like a button. |
Motion and sound
Motion
- A control's fill and text colour change over 150 ms on hover and when a toggle is pressed or released.
- A press scales the control to 97% and back over 150 ms.
- Reduced motion: colours and scale change at once.
Sound
- A rising pair of clicks when a toggle is pressed and a falling pair when it is released.
- Buttons and links are silent.
Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works
Accessibility
- It follows the WAI-ARIA toolbar pattern: the bar has the toolbar role and its controls share one tab stop.
- Name the bar with an aria-label, and every group and toggle group too. An icon-only control needs an aria-label of its own.
- A toggle is a button with aria-pressed. Pressed is the primary fill with the primary text colour against an empty box, so the state does not rest on a tint.
- A disabled control keeps its place in the arrow-key order and says it is disabled, so the bar's shape does not change under a screen reader.
- Every control is 32 pixels tall and at least 32 wide, above the 24 pixel minimum target.
- In a container narrower than its controls the bar wraps onto more lines. Under a glass material the bar is translucent, and its tint keeps the text at 4.5 to 1.
| Keys | Action |
|---|---|
| Tab | Move onto the bar, onto the control that last had the focus, and out again. The bar is one tab stop. |
| ← / → | Move to the previous or next control of a horizontal bar. Past the end it wraps. In right-to-left text the keys swap. |
| ↑ / ↓ | Move to the previous or next control of a vertical bar. |
| Enter / Space | Press the focused button or toggle. Enter follows the focused link. |
Source
The source comes with Pro
TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies
Files and dependencies
- Adds
components/ui/toolbar.tsx- Packages
@base-ui/react@1.9.0- Brings along
- ButtonToggleToggle group
Changelog
- 1.0.0 · 2026-12-03First release.