Toolbar
Groups related controls into a single keyboard navigation region.
Installation
Install the following dependencies:
Set up Installation, including states.ts, state-styles.ts, and interop.css for icons. Install Button, Input, Separator, and Toggle for shared styles and parts.
Copy and paste the following code into your project.
Update the import paths to match your project setup.
Usage
Give the toolbar an aria-label. In a horizontal toolbar, place at most one ToolbarInput last so arrow navigation does not conflict with moving the caret.
Use ToolbarToggle inside Toggle Group for mutually exclusive or multiple selections.
Using with Menu
Pass DropdownMenuTrigger to the button's render prop.
Using with Tooltip
Pass ToolbarButton to TooltipTrigger's render prop.
Using with NumberField
Use NumberFieldToolbarInput from Number Field as the last control.
Orientation
Use orientation to switch between horizontal and vertical navigation.
Disabled
Use disabled on the toolbar, a group, or an individual control; set focusableWhenDisabled={false} to skip a disabled control during navigation.
API reference
Parts accept Base UI Toolbar props, including render. Styled parts accept xstyle, className, and inline style. ToolbarToggle accepts Toggle props and focusableWhenDisabled (default true).
ToolbarButton and ToolbarLink
| Prop | Type | Default |
|---|---|---|
variant | "default" | "outline" | "secondary" | "ghost" | "destructive" | "link" | "ghost" (button), "link" (link) |
size | "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | "default" |
toolbarStyles
| Key | What it is |
|---|---|
root | The well, inset and nested corner |
vertical | Vertical arrangement |
group | Group layout |
separator | Separator spacing |
ghostOnWell | Row-highlight hover and open fill for ghost buttons |
button | Button base and focus ring |
variants, sizes | Button appearance maps |
input | Input base and focus ring |
Data attributes
| Attribute | On | Effect |
|---|---|---|
data-slot="toolbar" | root | Toolbar anatomy |
data-slot="toolbar-group" | group | Group anatomy |
data-slot="toolbar-button" | button | Action anatomy |
data-slot="toolbar-toggle" | toggle | Selection anatomy |
data-slot="toolbar-link" | link | Link anatomy |
data-slot="toolbar-input" | input | Input anatomy |
data-slot="toolbar-separator" | separator | Separator anatomy |
data-orientation | parts | Horizontal or vertical |
data-disabled | root, group, controls | Disabled state |
data-focusable | button, input | Disabled control remains focusable |
data-pressed | toggle | Selected state |
data-variant, data-size | button, link, toggle | Appearance |