Components

Toolbar

Headless ARIA toolbar primitives for grouped controls with roving keyboard navigation.

When to Use

Use Toolbar for a compact row or column of related controls, such as editor formatting tools. Use NavigationMenu or ordinary links for moving between pages, and use separate Buttons when the commands are not one logical group.

Features

  • Renders role="toolbar" with orientation.
  • Supports horizontal and vertical arrow-key navigation.
  • Supports left-to-right and right-to-left direction.
  • Supports buttons, links, separators, and toggle groups.
  • Registers toolbar items in DOM order.
  • Keeps styling, icons, and visual grouping outside the primitive.

Import

import { Toolbar } from "@flowstack-ui/atom";

Anatomy

<Toolbar.Root>
  <Toolbar.Button />
  <Toolbar.Link href="/" />
  <Toolbar.Separator />
  <Toolbar.ToggleGroup>
    <Toolbar.ToggleItem value="bold" />
  </Toolbar.ToggleGroup>
</Toolbar.Root>

API Reference

Root

Owns orientation, direction, item registration, and roving focus for the whole control group.

PropTypeDefault
orientation"horizontal" | "vertical""horizontal"
dir"ltr" | "rtl"Direction.Provider
loopbooleantrue
ariaLabelstring-
renderRenderProp-
asChildbooleanfalse
ARIA attributeValues
role"toolbar"
aria-labelValue from ariaLabel when provided
aria-orientationCurrent orientation
Data attributeValues
[data-slot]"toolbar"
[data-orientation]"horizontal" | "vertical"

Button

Renders a command button and registers it in the toolbar's roving focus order.

PropTypeDefault
disabledbooleanfalse
ariaLabelstring-
renderRenderProp-
asChildbooleanfalse
ARIA attributeValues
role"button" for a custom non-native element
aria-labelValue from ariaLabel when provided
aria-disabledtrue for a disabled custom element
Data attributeValues
[data-slot]"toolbar-button"
[data-disabled]Present when disabled

Renders a navigation link that participates in roving focus. Disabled links cannot navigate and are announced as disabled.

PropTypeDefault
hrefstringrequired
targetstring-
relstring-
disabledbooleanfalse
ariaLabelstring-
renderRenderProp-
asChildbooleanfalse
ARIA attributeValues
aria-labelValue from ariaLabel when provided
aria-disabledtrue when disabled
Data attributeValues
[data-slot]"toolbar-link"
[data-disabled]Present when disabled

Separator

Renders a semantic separator between control groups. Its orientation describes the separator line, not the Toolbar direction.

PropTypeDefault
orientation"horizontal" | "vertical""vertical"
renderRenderProp-
asChildbooleanfalse
ARIA attributeValues
role"separator"
aria-orientationSeparator orientation
Data attributeValues
[data-slot]"toolbar-separator"
[data-orientation]"horizontal" | "vertical"

ToggleGroup

Owns single or multiple pressed values for related ToggleItem parts without creating another Tab stop outside the Toolbar's roving focus model.

PropTypeDefault
type"single" | "multiple""single"
valuestring | string[]-
defaultValuestring | string[][]
onValueChange(value) => void-
disabledbooleanfalse
ariaLabelstring-
renderRenderProp-
asChildbooleanfalse
ARIA attributeValues
role"group"
aria-labelValue from ariaLabel when provided
Data attributeValues
[data-slot]"toolbar-toggle-group"
[data-disabled]Present when disabled

ToggleItem

Renders one pressed button, participates in Toolbar roving focus, and reads its selection state from ToggleGroup.

PropTypeDefault
valuestringrequired
disabledbooleanfalse
ariaLabelstring-
renderRenderProp-
asChildbooleanfalse
ARIA attributeValues
role"button" for a custom non-native element
aria-pressedCurrent selected state
aria-labelValue from ariaLabel when provided
aria-disabledtrue when disabled
Data attributeValues
[data-slot]"toolbar-toggle-item"
[data-state]"on" | "off"
[data-value]Item value
[data-disabled]Present when disabled

Advanced compound parts can use useToolbarContext, useToolbarToggleContext, and useToolbarItem with their matching public providers.

Examples

Formatting Toolbar

import { Toolbar } from "@flowstack-ui/atom";

export default function FormattingToolbar() {
  return (
<Toolbar.Root ariaLabel="Formatting">
  <Toolbar.Button ariaLabel="Undo">Undo</Toolbar.Button>
  <Toolbar.Button ariaLabel="Redo">Redo</Toolbar.Button>
  <Toolbar.Separator />
  <Toolbar.ToggleGroup type="multiple" ariaLabel="Text style">
    <Toolbar.ToggleItem value="bold">Bold</Toolbar.ToggleItem>
    <Toolbar.ToggleItem value="italic">Italic</Toolbar.ToggleItem>
  </Toolbar.ToggleGroup>
</Toolbar.Root>
  );
}

Vertical Toolbar

import { Toolbar } from "@flowstack-ui/atom";

export default function DrawingToolbar() {
  return (
<Toolbar.Root orientation="vertical" ariaLabel="Drawing tools">
  <Toolbar.Button>Move</Toolbar.Button>
  <Toolbar.Button>Pen</Toolbar.Button>
</Toolbar.Root>
  );
}

Accessibility

Toolbar follows the WAI-ARIA toolbar pattern. Use it for groups of controls, not page navigation. Local dir overrides Direction.Provider.

KeyDescription
ArrowRightMoves focus to the next item when horizontal LTR, previous in RTL.
ArrowLeftMoves focus to the previous item when horizontal LTR, next in RTL.
ArrowDownMoves focus to the next item when vertical.
ArrowUpMoves focus to the previous item when vertical.
HomeMoves focus to the first enabled item.
EndMoves focus to the last enabled item.

Changelog

See CHANGELOG.md.