Installation
Usage
Examples
Single Selection
Only one item can be selected at a time.Multiple Selection
Multiple items can be selected simultaneously.Variants
Sizes
Spacing
Control the spacing between toggle items.Disabled
Controlled
Component Code
Props
ToggleGroup
| Prop | Type | Default | Description |
|---|---|---|---|
type | "single" | "multiple" | - | Selection mode (required) |
variant | "default" | "outline" | "default" | Visual style variant |
size | "sm" | "default" | "lg" | "default" | Size of all toggle items |
spacing | number | 0 | Gap between items (0 = connected) |
value | string | string[] | - | Controlled value(s) |
defaultValue | string | string[] | - | Default value(s) (uncontrolled) |
onValueChange | (value: string | string[]) => void | - | Callback when value changes |
disabled | boolean | false | Disables all toggle items |
orientation | "horizontal" | "vertical" | "horizontal" | Layout orientation |
className | string | - | Additional CSS classes |
ToggleGroupItem
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | - | Unique value for this item (required) |
variant | "default" | "outline" | - | Overrides group variant |
size | "sm" | "default" | "lg" | - | Overrides group size |
disabled | boolean | false | Disables this specific item |
className | string | - | Additional CSS classes |
aria-label | string | - | Accessible label |
Composition Patterns
Text Formatting Toolbar
Accessibility
- Uses
role="group"for the container - Individual items use
role="button"witharia-pressed - Keyboard navigation with arrow keys
- Always include
aria-labelfor icon-only items - Disabled state prevents interaction