Searching Puzzle Pieces

Type to search Puzzle Pieces.

Toggle Group

A config-first joined row of pressed-state buttons. It's a pressed-buttons pattern, not a radio group — even in single mode you can click the active item again to deselect it. The parent owns value.

Alignment: left

Installation

Copy the piece into your app — it compiles with your build and the code is yours:

puzzle add piece toggle-group

Requires the pieces.css tokens merged into your app styles (see Introduction).

Usage

import ToggleGroup from '@/components/ui/ToggleGroup.pzl';
<ToggleGroup items={ aligns } value={ align } @change={ setAlign } label="Text alignment"/>

Multiple

Marks: bold

Icon-only groups

Per-item SVG props aren't possible in Puzzle: a component only inlines SVG through the compile-time svg block, which needs a literal file path, not per-item data. So an item's icon field is never rendered — the label is what shows.

For an icon-only look today, pass a short or emoji label. It stays a real accessible name, so screen readers still announce the control:

// icon field is ignored — use a short/emoji label as the accessible name
data(params, props) {
  return {
    aligns: [
      { value: 'left', label: '⇤' },
      { value: 'center', label: '↔' },
      { value: 'right', label: '⇥' },
    ],
  };
}

<ToggleGroup items={ aligns } value={ align } @change={ setAlign } label="Text alignment"/>