Installation
- CLI
- Manual
Usage
Import the toggle group components:API Reference
ToggleGroup
The container component that wraps toggle items and manages their state. Props ExtendsReact.ComponentProps<typeof ToggleGroupRoot> from Base UI.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default" | "outline" | "default" | The visual style variant for all items |
size | "default" | "sm" | "lg" | "default" | The size of all items |
orientation | "horizontal" | "vertical" | "horizontal" | The layout direction |
multiple | boolean | false | Allow multiple items to be pressed |
defaultValue | string | string[] | - | Default selected value(s) |
value | string | string[] | - | Controlled selected value(s) |
onValueChange | (value: string | string[]) => void | - | Callback when selection changes |
disabled | boolean | false | Disable all items |
ToggleGroupItem
An individual toggle button within the group. Props Extends all Toggle props.| Prop | Type | Description |
|---|---|---|
value | string | Required unique identifier for the item |
disabled | boolean | Disable this specific item |
Examples
Default (Single Selection)
By default, only one item can be selected at a time:Multiple Selection
Allow multiple items to be selected simultaneously:Vertical Orientation
Stack toggle items vertically:Sizes
Control the size of all items in the group:Disabled
Disable the entire group or individual items:Controlled
Control the selection state with React state:With Text Labels
Combine icons with text for better clarity:Variants
Default
Transparent background with subtle hover states:Outline
Bordered variant with connected items:Accessibility
- Uses proper ARIA roles and attributes for toggle group pattern
- Keyboard navigation with arrow keys between items
- Space and Enter keys to toggle items
- Clearly indicates pressed state to screen readers
- Always include
aria-labelon icon-only toggle items
