Skip to Content
⭐️ Leave a star →
ComponentsToolbar

Toolbar

An accessible role="toolbar" container with roving tabindex — the whole group is a single tab stop and arrow keys move focus between items (Home/End jump to the ends). Compose it from Toolbar.Button, Toolbar.Toggle, Toolbar.Link, and Toolbar.Separator.

Features

Renders as role=“toolbar” with aria-orientation.
Roving tabindex — a single tab stop, arrow keys move focus between items.
Home/End jump to the first/last item; disabled items are skipped.
Horizontal or vertical orientation with optional focus looping.
Built-in Toggle item with controlled/uncontrolled pressed state.
Button, Toggle, Link, and Separator sub-components.

Example

import { Toolbar } from '@wire-ui/react' <Toolbar.Root aria-label="Text formatting"> <Toolbar.Toggle aria-label="Bold"><b>B</b></Toolbar.Toggle> <Toolbar.Toggle aria-label="Italic"><i>I</i></Toolbar.Toggle> <Toolbar.Separator /> <Toolbar.Button aria-label="Align left">⬅</Toolbar.Button> <Toolbar.Link href="#">Help</Toolbar.Link> </Toolbar.Root>

Styling

Toolbar.Toggle exposes data-state ("on" / "off") and aria-pressed for the pressed look. Toolbar.Root and Toolbar.Separator expose data-orientation. Each interactive item is wired into roving tabindex automatically.

<Toolbar.Toggle className=" text-black data-[state=on]:bg-black data-[state=on]:text-white "> <b>B</b> </Toolbar.Toggle> <Toolbar.Root className=" inline-flex gap-1 data-[orientation=vertical]:flex-col " />

Using data attributes

Toolbar.Root sets data-orientation. Toolbar.Toggle sets data-state. All interactive items carry data-toolbar-item. Toolbar.Separator sets data-orientation (perpendicular to the toolbar’s axis).

/* Pressed toggle */ [data-state="on"] { background: #000; color: #fff; } /* Vertical toolbar */ [data-orientation="vertical"] { flex-direction: column; }

Root props

PropTypeDefaultDescription
orientation'horizontal' | 'vertical''horizontal'Layout + arrow-key axis
loopbooleantrueWrap focus from last → first and vice versa

Also accepts all native <div> attributes.

Button props

Toolbar.Button accepts all native <button> attributes. It is registered into the toolbar’s roving-focus group.

Toggle props

PropTypeDefaultDescription
pressedbooleanControlled pressed state
defaultPressedbooleanfalseInitial pressed state (uncontrolled)
onPressedChange(pressed: boolean) => voidCalled when the pressed state changes

Also accepts all native <button> attributes (including disabled).

Toolbar.Link accepts all native <a> attributes (e.g. href). It is registered into the toolbar’s roving-focus group.

Separator props

PropTypeDefaultDescription
orientation'horizontal' | 'vertical'perpendicular to RootVisual orientation; defaults to the axis perpendicular to the toolbar

Also accepts all native <div> attributes.

Data attributes

AttributeElementValues
data-orientationRoot, Separator"horizontal" / "vertical"
data-stateToggle"on" / "off"
data-toolbar-itemButton, Toggle, LinkPresent on every roving-focus item

Root sets role="toolbar" and aria-orientation. Separator sets role="separator" and aria-orientation. Toggle sets aria-pressed. Each item uses roving tabindex (tabIndex={0} for the active item, -1 for the rest).

Accessibility

  • Implements the WAI-ARIA toolbar pattern with roving tabindex.
  • The toolbar is a single tab stop; arrow keys move focus between items along the orientation axis.
  • Disabled items (disabled or aria-disabled="true") are skipped during arrow-key navigation.
  • Provide an aria-label (or aria-labelledby) on Toolbar.Root to name the toolbar.

Keyboard Interactions

KeyDescription
ArrowRight / ArrowDownFocus the next item (axis depends on orientation).
ArrowLeft / ArrowUpFocus the previous item.
HomeFocus the first item.
EndFocus the last item.
Space / EnterActivates a Button/Link or toggles a Toggle.
TabMoves focus into the toolbar (single tab stop), then out of it.
Last updated on

MIT License © 2026 wire-ui

Toolbar – Wire UI