Skip to content
RefineUI

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.

Overview

Machine-readable contract from Component Spec.

component: toolbarexport: Toolbarversion: 1attributes: data-refineui=toolbar

Anatomy

Partdata-refineui
roottoolbar
grouptoolbar-group
buttontoolbar-button
toggletoolbar-toggle-button
dividertoolbar-divider

Variants

AxisValues
sizesm, md, lg
orientationhorizontal, vertical

States

ScopeCategoryValues
componentpseudofocus-visible
componentenvironmentforced-colors, dir

Accessibility

SlotElementRoleLabeling
toolbardivtoolbaraccessibleName: required
toolbar-groupdivgroup—
toolbar-dividerdivseparator—
toolbar-buttonbutton——
toolbar-toggle-buttonbutton——

Keyboard

KeyActionNative
ArrowRightnext-trigger—
ArrowLeftprevious-trigger—
ArrowDownnext-trigger—
ArrowUpprevious-trigger—
Homefirst-trigger—
Endlast-trigger—
Enteractivatetrue
Spaceactivatetrue

Focus

SectionPropertyValue
visualrequiredtrue
visualselector:focus-visible
behaviorrovingtrue

Layout

PropertyValue
directionlogical
rtltrue
npm install @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>;

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>

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>

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.

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 (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.

KeyAction
TabMoves into the toolbar (to the last focused item) and out of it. The toolbar is a single Tab stop.
ArrowRight / ArrowLeftNext or previous item in a horizontal toolbar. Reversed in RTL.
ArrowDown / ArrowUpNext or previous item when orientation="vertical".
Home / EndFirst or last item. Inside a text field, these keys move the caret instead.
Enter / SpaceActivates 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.

PropDefaultTypeDescription
label—stringAccessible name, applied as aria-label. Always provide one.
attachedfalsebooleanRaised 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.
looptruebooleanWrap focus between the last and first item.
PropDefaultTypeDescription
orientationinherited"horizontal" | "vertical"Overrides the direction inherited from Toolbar.
aria-label—stringNames the group (role="group").

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.

PropDefaultTypeDescription
variant"ghost"ButtonProps["variant"]Button visual variant.
layout"icon""icon" | "label"Use "label" for a text button.
sizetoolbar size"sm" | "md" | "lg"Overrides the cascaded size.

Accepts every ToolbarButton prop, plus:

PropDefaultTypeDescription
pressed—booleanControlled pressed state.
defaultPressedfalsebooleanInitial state when uncontrolled.
onPressedChange—(pressed: boolean) => voidCalled with the next state on press.
PropDefaultTypeDescription
orientationinherited"horizontal" | "vertical"Overrides the direction inherited from Toolbar.