How to build an accessible ToggleGroup in React

Single mode renders role="radiogroup" with role="radio" + aria-checked items; multiple mode uses a plain group of buttons with aria-pressed. Roving tabindex makes the set one tab stop and arrow keys move between items, matching the APG radiogroup/toolbar patterns

When to use a ToggleGroup

When not to use it

Keyboard interactions

Role radiogroup, verified at WCAG 2.2-AA.

Common mistakes

Avoid: <ToggleGroup type="single" items={items} onValueChange={save} />

Prefer: <ToggleGroup type="single" value={align} onValueChange={setAlign} items={items} />

Single-select used as a controlled value should be driven by value/onValueChange so the source of truth lives with the parent

Example

<ToggleGroup type="single" defaultValue="left" items={[{ value: "left", label: "Left" }, { value: "center", label: "Center" }, { value: "right", label: "Right" }]} />

See the full ToggleGroup reference →