Toolbar
A WAI-ARIA role="toolbar" container that groups buttons, toggles, and separators into a single Tab stop with roving-tabindex arrow-key navigation. Config-first from an items array; value-first @press / @toggle callbacks.
Installation
Copy the piece into your app — it compiles with your build and the code is yours:
puzzle add piece toolbar
Requires the pieces.css tokens merged into your app styles (see Introduction).
Usage
import Toolbar from '@/components/ui/Toolbar.pzl';
<Toolbar label="Text formatting" items={ items } @toggle={ setMark } @press={ act }/>Mixed controls
Vertical orientation
Keyboard
The whole toolbar is a single Tab stop. Once focus is inside, arrow keys move between controls (wrapping at the ends) and skip separators and disabled items:
- Tab
- Move into / out of the toolbar (one stop for the whole group).
- ← →
- Previous / next control (horizontal toolbars).
- ↑ ↓
- Previous / next control (vertical toolbars).
- Home End
- First / last enabled control.
- Enter Space
- Activate the focused button or toggle.
Accessibility
The root is a role="toolbar" with an aria-label (default "Toolbar") and an aria-orientation matching the orientation prop. Exactly one control carries tabindex="0" at a time (roving tabindex); the rest are -1.
Toggles carry aria-pressed; the parent owns each toggle's pressed state and writes it back from @toggle({ value, pressed }). Separators are role="separator" and are never focusable.
label is always required on every control — it is the accessible name. For an icon-only control set iconOnly: true: the label renders sr-only and is mirrored onto the control's title.