Toolbar
A container for interactive controls with arrow-key navigation.
Toolbar groups related controls, such as text formatting, alignment, or clipboard actions, into a single Tab stop that you move through with the arrow keys. Compose it from ToolbarGroup, ToolbarButton, ToolbarToggleButton, and ToolbarDivider. Set size once on the toolbar and every control inside follows it.
Contract
Section titled “Contract”Overview
Machine-readable contract from Component Spec.
Anatomy
| Part | data-refineui |
|---|---|
| root | toolbar |
| group | toolbar-group |
| button | toolbar-button |
| toggle | toolbar-toggle-button |
| divider | toolbar-divider |
Variants
| Axis | Values |
|---|---|
| size | sm, md, lg |
| orientation | horizontal, vertical |
States
| Scope | Category | Values |
|---|---|---|
| component | pseudo | focus-visible |
| component | environment | forced-colors, dir |
Accessibility
| Slot | Element | Role | Labeling |
|---|---|---|---|
| toolbar | div | toolbar | accessibleName: required |
| toolbar-group | div | group | — |
| toolbar-divider | div | separator | — |
| toolbar-button | button | — | — |
| toolbar-toggle-button | button | — | — |
Keyboard
| Key | Action | Native |
|---|---|---|
| ArrowRight | next-trigger | — |
| ArrowLeft | previous-trigger | — |
| ArrowDown | next-trigger | — |
| ArrowUp | previous-trigger | — |
| Home | first-trigger | — |
| End | last-trigger | — |
| Enter | activate | true |
| Space | activate | true |
Focus
| Section | Property | Value |
|---|---|---|
| visual | required | true |
| visual | selector | :focus-visible |
| behavior | roving | true |
Layout
| Property | Value |
|---|---|
| direction | logical |
| rtl | true |
Installation
Section titled “Installation”npm install @refineui/react @refineui/tokens yarn add @refineui/react @refineui/tokens pnpm add @refineui/react @refineui/tokens bun add @refineui/react @refineui/tokens import { Toolbar, ToolbarButton, ToolbarGroup, ToolbarDivider, ToolbarToggleButton, WebIcon,} from "@refineui/react"; <Toolbar label="Text formatting"> <ToolbarGroup aria-label="Text style"> <ToolbarToggleButton aria-label="Highlight"><WebIcon name="highlight" /></ToolbarToggleButton> <ToolbarToggleButton aria-label="Link"><WebIcon name="link" /></ToolbarToggleButton> </ToolbarGroup> <ToolbarDivider /> <ToolbarGroup aria-label="Clipboard"> <ToolbarButton aria-label="Copy"><WebIcon name="copy" /></ToolbarButton> <ToolbarButton aria-label="Cut"><WebIcon name="cut" /></ToolbarButton> </ToolbarGroup></Toolbar>; Examples
Section titled “Examples”Attached
Section titled “Attached”attached puts the toolbar on a raised rounded surface, which suits a floating action bar over a canvas or editor.
<Toolbar label="Text formatting" attached> …</Toolbar> Vertical
Section titled “Vertical”With orientation="vertical", the controls stack vertically and the up and down arrow keys move focus. Groups and dividers inherit the direction.
<Toolbar label="Tools" orientation="vertical" attached> <ToolbarGroup aria-label="Tool">…</ToolbarGroup> <ToolbarDivider /> <ToolbarGroup aria-label="Zoom">…</ToolbarGroup></Toolbar> Groups
Section titled “Groups”ToolbarGroup always wraps its ghost buttons in the same tube as ButtonGroup: the subtle track and thin border from SegmentedControl, with corners that follow the Button radius. A pressed toggle switches from the ghost to the secondary Button variant, with no custom colors. Every group in a toolbar looks the same, so dividers are what split them apart.
Toggle buttons
Section titled “Toggle buttons”ToolbarToggleButton keeps its pressed state in aria-pressed and renders the secondary Button variant while pressed. It’s uncontrolled with defaultPressed, or controlled with pressed and onPressedChange. For single choice, such as alignment, control it from shared state:
const [align, setAlign] = useState("left"); <ToolbarGroup aria-label="Alignment"> {["left", "center", "right"].map((value) => ( <ToolbarToggleButton key={value} aria-label={`Align ${value}`} pressed={align === value} onPressedChange={() => setAlign(value)} > <WebIcon name={`text-align-${value}`} /> </ToolbarToggleButton> ))}</ToolbarGroup>; Size cascading
Section titled “Size cascading”size (sm, md, or lg, default sm) cascades to ToolbarButton, Button, and Field controls such as Input and Select. A child that sets size explicitly keeps its own.
Keyboard
Section titled “Keyboard”| Key | Action |
|---|---|
Tab | Moves into the toolbar (to the last focused item) and out of it. The toolbar is a single Tab stop. |
ArrowRight / ArrowLeft | Next or previous item in a horizontal toolbar. Reversed in RTL. |
ArrowDown / ArrowUp | Next or previous item when orientation="vertical". |
Home / End | First or last item. Inside a text field, these keys move the caret instead. |
Enter / Space | Activates the focused button or toggles it. |
Disabled items are skipped, and focus wraps around unless loop={false}. Composite widgets such as SegmentedControl count as one stop, and inside a text field the arrow keys move the caret until it reaches the edge.
API Reference
Section titled “API Reference”Toolbar
Section titled “Toolbar”| Prop | Default | Type | Description |
|---|---|---|---|
| label | — | string | Accessible name, applied as aria-label. Always provide one. |
| attached | false | boolean | Raised rounded surface for a floating action bar. |
| orientation | "horizontal" | "horizontal" | "vertical" | Layout direction and arrow-key axis. Inherited by groups and dividers. |
| size | "sm" | "sm" | "md" | "lg" | Cascades to Buttons and Field controls inside. |
| loop | true | boolean | Wrap focus between the last and first item. |
ToolbarGroup
Section titled “ToolbarGroup”| Prop | Default | Type | Description |
|---|---|---|---|
| orientation | inherited | "horizontal" | "vertical" | Overrides the direction inherited from Toolbar. |
| aria-label | — | string | Names the group (role="group"). |
ToolbarButton
Section titled “ToolbarButton”An icon-only ghost Button by default. Its size follows the toolbar. Icon-only buttons need an aria-label. All other props are forwarded to Button.
| Prop | Default | Type | Description |
|---|---|---|---|
| variant | "ghost" | ButtonProps["variant"] | Button visual variant. |
| layout | "icon" | "icon" | "label" | Use "label" for a text button. |
| size | toolbar size | "sm" | "md" | "lg" | Overrides the cascaded size. |
ToolbarToggleButton
Section titled “ToolbarToggleButton”Accepts every ToolbarButton prop, plus:
| Prop | Default | Type | Description |
|---|---|---|---|
| pressed | — | boolean | Controlled pressed state. |
| defaultPressed | false | boolean | Initial state when uncontrolled. |
| onPressedChange | — | (pressed: boolean) => void | Called with the next state on press. |
ToolbarDivider
Section titled “ToolbarDivider”| Prop | Default | Type | Description |
|---|---|---|---|
| orientation | inherited | "horizontal" | "vertical" | Overrides the direction inherited from Toolbar. |