Toggle Group

A set of toggles where one or multiple can be pressed. Inherits Toggle's variant/size via context. Useful for alignment/formatting toolbars.

Single-select (text alignment)

Multi-select (formatting marks)

Sizes

Installation

pnpm
pnpm dlx @hex-core/cli add toggle-group

Formatting group

Multiple-select toggle group for text formatting

tsx
<ToggleGroup type="multiple">
  <ToggleGroupItem value="bold" aria-label="Bold">B</ToggleGroupItem>
  <ToggleGroupItem value="italic" aria-label="Italic">I</ToggleGroupItem>
  <ToggleGroupItem value="underline" aria-label="Underline">U</ToggleGroupItem>
</ToggleGroup>

API Reference

PropTypeDefaultDescription
typerequired
"single" | "multiple"Single allows one pressed at a time, multiple allows many
value
objectControlled pressed value(s). string when type='single', string[] when type='multiple'
defaultValue
objectDefault pressed value(s). string when type='single', string[] when type='multiple'
onValueChange
functionCallback on value change
variant
"default" | "outline"defaultInherited by all ToggleGroupItems
size
"default" | "sm" | "lg"defaultInherited by all ToggleGroupItems
disabled
booleanfalseDisable all items

AI Guidance

When to use

Use for toolbar toggles where users pick one of many (type='single') or multiple (type='multiple'): text alignment, formatting (bold/italic/underline), view modes.

When not to use

Don't use for form radio fields (use RadioGroup). Don't use for standalone two-state buttons (use Toggle). Don't use for navigation (use Tabs).

Common mistakes

  • Forgetting the type prop (required)
  • Missing aria-label on icon-only items
  • Using for form submission without name prop

Accessibility

Radix implements the WAI-ARIA toolbar pattern with roving focus. Arrow keys move focus, Space/Enter toggles. Each icon-only item needs aria-label.

Related components

Token budget: 500