Toolbar
A row of actions and toggles with arrow-key navigation
Primitive
A toolbar puts the controls for one context on a single shell, like an editor's formatting bar or a canvas's tool palette. Tab enters and leaves it in one stop, and arrow keys move between controls.
For a short row of actions without arrow keys, use ButtonGroup. For one set of exclusive options, use ToggleGroup.
Preview
Installation
Usage
Composition
Leave variant unset on ToolbarButton; it takes the toolbar's quiet style. To open a menu, popover, or dialog, render its trigger as a ToolbarButton.
The toolbar never gets narrower than its controls. If it may not fit on small screens, put it in a container that scrolls sideways, such as a ScrollArea with nativeScroll. To let a flex-1 ToolbarInput shrink instead, pass className="min-w-0" to the toolbar.
Examples
Variants
Use variant to pick the shell the controls sit on.
| Variant | Description |
|---|---|
elevated | The default. A raised surface, for floating bars. |
outline | An outline Button's fill and border. |
soft | A secondary Button's fill, for editor chrome. |
ghost | No shell, for bars inside a card or header. |
Size
Use size to match the toolbar to a Button of the same size; its controls scale their padding, text, and icons with it.
With Input
Use ToolbarInput for a quiet field in the row; give one button a variant to mark the main action.
Orientation
Set orientation="vertical" for a tool palette; arrow keys follow the axis.
Accessibility
Labels
Give the toolbar an aria-label that names what it controls ("Text formatting"), and every icon-only control its own.
Keyboard
Tab moves focus into and out of the toolbar in one stop. Arrow keys move between controls, and focus loops unless you set loopFocus={false}. A disabled control stays focusable, so keyboard users can still find it.
Toggles
ToolbarToggle exposes its state with aria-pressed, and a pressed toggle keeps a deeper tint than hover. In forced-colors mode a pressed toggle gets a Highlight border.
API Reference
The Toolbar is built on top of Base UI's Toolbar. All Base UI props are supported. The documentation below only covers custom props and modified defaults specific to our implementation.
For the complete Base UI API, see the Base UI Toolbar documentation.
Props
Toolbar
The shell. Wraps Base UI's Toolbar.Root.
ToolbarButton
A quiet Button in the toolbar. Wraps Base UI's Toolbar.Button and takes Button's props.
Notes
ToolbarToggle
A Toggle that stays pressed when on. Wraps Base UI's Toolbar.Button and takes Toggle's props except variant and size.
ToolbarToggleGroup
Toggles that share a value, like text alignment. Wraps Base UI's ToggleGroup and lays its items into the toolbar's row.
ToolbarGroup
Groups controls, for example to disable them together with disabled. Wraps Base UI's Toolbar.Group and adds no layout.
ToolbarSeparator
A line between controls, across the toolbar's axis. Arrow keys skip it.
ToolbarInput / ToolbarLink
A quiet field and a quiet link. Wrap Base UI's Toolbar.Input and Toolbar.Link.
Upgrading
If you're reinstalling over an earlier version, check these changes:
| Before | Now |
|---|---|
Installed as cubby-ui/toolbar.tsx | Installs into a cubby-ui/toolbar/ folder with toolbar.css. Import from @/components/ui/cubby-ui/toolbar/toolbar and delete the old file. |
variant="default" | variant="elevated", still the default. |
level and shadowLevel on Toolbar | Removed; elevated uses a fixed surface. |
ToolbarButton defaulted to variant="ghost" | Leave variant unset for the quiet style; a set variant marks the main action. |
ToolbarButton defaulted to size="icon_sm" | Size follows the toolbar. An icon-only button needs aria-label or aria-labelledby to stay square, or pass size. |
ToolbarGroup laid out its buttons | It adds no layout; use ToolbarSeparator to split clusters. |