Skip to content

ToggleGroup

Set of related toggle buttons that act together as a single, segmented control.

  • stable
  • since v0.1.0
  • 3.01 kB
  • feedback
  • control
  • segmented

Exposes roving focus, arrow-key navigation, and per-item aria-pressed. Provide an aria-label on the group so its purpose is announced.

Preview
Open
tsx

Pass type="single" for mutually exclusive options or type="multiple" for independent toggles.

Preview
Open
tsx
Preview
Open
tsx

ToggleGroup ships three variants — ghost (default), outline, and solid — applied to every item via context.

Preview
Open
tsx

Four sizes are available: xs, sm, md (default), and lg.

Preview
Open
tsx

Set attached to render a segmented control — items float as tiles inside a tinted, padded track (the same container NumberInput and ButtonGroup use), with the selected item raised.

Preview
Open
tsx
PropTypeDefaultDescription
type*
"single"|"multiple"
value
string|string[]
Currently selected value (controlled). Currently selected values (controlled).
defaultValue
string|string[]
Initial selected value (uncontrolled). Initial selected values (uncontrolled).
onValueChange
((value: string) => void) | ((value: string[]) => void)
Fires with the next selected value. Empty string when nothing selected. Fires with the next array of selected values.
disabled
boolean
Whether the group is disabled.
rovingFocus
boolean
Whether the group enforces a non-empty selection in single mode.
children
ReactNode
Children — should be `<ToggleGroupItem>` elements.
className
string
aria-label
string
Accessible label for the group.
aria-labelledby
string
Reference an external visible label.
size
"xs"|"sm"|"md"|"lg"
"md"
Pixel scale applied to every child toggle via context. One of `xs`, `sm`, `md`, `lg`.
variant
"ghost"|"outline"|"solid"
"ghost"
Visual style applied to every child toggle via context. One of `ghost`, `outline`, `solid`.
attached
boolean
Render children as a segmented control: items float inside a tinted, padded track (the same container `NumberInput` and `ButtonGroup` use), with the selected item raised.
  • Items expose aria-pressed (multiple) or aria-checked (single) automatically.
  • Roving focus + arrow-key navigation moves between items; Home and End jump to ends.
  • Always provide an aria-label on ToggleGroup so screen readers can announce the group purpose.
  • type="single" enforces one active value; type="multiple" allows zero or more.
  • The shared size and variant cascade through context so individual items stay visually consistent.
  • Use single-select groups for mutually exclusive options like text alignment.
  • Use multi-select groups for independent formatting toggles (bold, italic, underline).
  • Reach for attached when you want a segmented control look.
  • Keep groups to a small number of items (3–5) so they stay scannable.