This page as markdown: /toolbar.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt

Toolbar

Status: stable

A row or column of controls that is one tab stop, with arrow-key movement between its items (role="toolbar"), over Base UI Toolbar. Items reuse Button's ghost variants and Input, so they follow density like every other control.

Keywords: toolbar, action bar, button row, icon buttons, formatting bar, roving focus, arrow keys, tool chrome, editor toolbar

Usage

Use Toolbar when three or more related controls sit together and act on the same thing — a text selection, a canvas, a document, a table. Tab lands on the toolbar once and the arrow keys move along it, so a keyboard user crosses an editor's twelve buttons in one keystroke instead of twelve. It works in both registers: ghost sm buttons on a page, compact icon-xs buttons inside a Workspace.

Best practices

Anatomy

Part Required Description
Toolbar yes The root (role="toolbar"). Owns orientation, loopFocus and disabled for everything inside it.
ToolbarButton yes An action. Button's ghost variants by default; render composes a menu trigger, popover trigger or Toggle into the toolbar.
ToolbarGroup no A run of related items. disabled disables the whole run.
ToolbarSeparator no A hairline between groups, oriented across the toolbar. Never a focus stop.
ToolbarInput no A compact Input that joins the arrow-key order — a search or find field in the bar.
ToolbarLink no An styled like a ToolbarButton, for a link that sits among the actions.

Subcomponents

Name Type Description
ToolbarButton { variant?: buttonVariants variant (default "ghost"); size?: buttonVariants size (default "sm"); disabled?: boolean; focusableWhenDisabled?: boolean (default true); render?: ReactElement } + Base UI Toolbar.Button props A toolbar action, styled exactly like
ToolbarLink { href?: string; variant?: buttonVariants variant (default "ghost"); size?: buttonVariants size (default "sm"); render?: ReactElement } + Base UI Toolbar.Link props An in the toolbar's arrow-key order, styled like a ToolbarButton.
ToolbarInput { disabled?: boolean; focusableWhenDisabled?: boolean (default true) } + Base UI Toolbar.Input / native input props Sable's Input at the sm control height (w-40 by default; override with className). Arrow keys leave the field so it does not trap the row.
ToolbarGroup { disabled?: boolean } + Base UI Toolbar.Group props Groups related items; disabled disables all of them.
ToolbarSeparator Base UI Toolbar.Separator props + className A hairline-strong rule across the toolbar's axis, exposed as role="separator" and skipped by the arrow keys.

Props

Name Type Default Description
orientation "horizontal" | "vertical" "horizontal" Which arrow keys move focus (Left/Right or Up/Down) and which way the items stack. Separators turn to match.
loopFocus boolean true Arrowing past the last item wraps to the first, and back.
disabled boolean false Disables every item. Items stay focusable (aria-disabled) so the row keeps its shape under the keyboard.
aria-label string — Names the toolbar for assistive technology. Always set it.
className string — Layout overrides — e.g. flex-1 to let the toolbar fill a bar.

Variants

Tokens used

foreground, accent, accent-foreground, ring, hairline-strong, input, card

Motion

Accessibility

Related

Examples

Formatting toolbar

import { Icon, Toggle, ToggleGroup, Toolbar, ToolbarButton, ToolbarGroup, ToolbarLink, ToolbarSeparator } from "@sableui/react"

<Toolbar aria-label="Text formatting">
  <ToolbarGroup aria-label="History">
    <ToolbarButton size="icon-sm" aria-label="Undo">
      <Icon name="arrow-left" />
    </ToolbarButton>
    <ToolbarButton size="icon-sm" aria-label="Redo">
      <Icon name="arrow-right" />
    </ToolbarButton>
  </ToolbarGroup>
  <ToolbarSeparator />
  <ToggleGroup multiple aria-label="Style">
    <ToolbarButton size="icon-sm" aria-label="Bold" render={<Toggle value="bold" />}>
      <Icon name="bold" />
    </ToolbarButton>
    <ToolbarButton size="icon-sm" aria-label="Italic" render={<Toggle value="italic" />}>
      <Icon name="italic" />
    </ToolbarButton>
  </ToggleGroup>
  <ToolbarSeparator />
  <ToolbarLink href="/help">Help</ToolbarLink>
</Toolbar>

With a menu trigger and a search field

import { Menu, MenuContent, MenuItem, MenuTrigger, Toolbar, ToolbarButton, ToolbarInput, ToolbarSeparator } from "@sableui/react"

<Toolbar aria-label="Table">
  <ToolbarButton>Export</ToolbarButton>
  <Menu>
    <ToolbarButton render={<MenuTrigger />}>View</ToolbarButton>
    <MenuContent>
      <MenuItem>Compact rows</MenuItem>
      <MenuItem>Comfortable rows</MenuItem>
    </MenuContent>
  </Menu>
  <ToolbarSeparator />
  <ToolbarInput aria-label="Search rows" placeholder="Search" />
</Toolbar>

Vertical tool rail

import { Icon, Toolbar, ToolbarButton, ToolbarSeparator } from "@sableui/react"

<Toolbar orientation="vertical" aria-label="Tools">
  <ToolbarButton size="icon-sm" aria-label="Select">
    <Icon name="arrow-up" />
  </ToolbarButton>
  <ToolbarButton size="icon-sm" aria-label="Draw">
    <Icon name="edit" />
  </ToolbarButton>
  <ToolbarSeparator />
  <ToolbarButton size="icon-sm" aria-label="Delete" disabled>
    <Icon name="trash" />
  </ToolbarButton>
</Toolbar>

In a workspace bar

import { Icon, Toolbar, ToolbarButton, WorkspaceBar } from "@sableui/react"

<WorkspaceBar>
  <Toolbar aria-label="Document" className="flex-1">
    <ToolbarButton size="xs">File</ToolbarButton>
    <ToolbarButton size="xs">Edit</ToolbarButton>
    <ToolbarButton size="icon-xs" aria-label="Share" className="ms-auto">
      <Icon name="share" />
    </ToolbarButton>
  </Toolbar>
</WorkspaceBar>