Component
ToggleGroup is a component that allows you to group multiple toggles together. Useful for when you want to allow users to select multiple options. For example, a user can select multiple filters for a search.
View component changelogRoot component for the ToggleGroup component.
| Prop | Type | Default |
|---|---|---|
type | enum | single |
multiple | boolean | false |
variant | string | -- |
size | string | -- |
className | string | '' |
loop | boolean | true |
orientation | enum | horizontal |
value | string[] | -- |
defaultValue | string[] | [] |
onValueChange | (value: string[]) => void | -- |
color | string | null |
customRootClass | string | '' |
disabled | boolean | false |
dir | enum | ltr |
rovingFocus | boolean | true |
asChild | boolean | false |
children | React.ReactNode | null |
Item component for the ToggleGroup component.
| Prop | Type | Default |
|---|---|---|
children | React.ReactNode | null |
value | any | null |
iconOnly | boolean | false |
className | string | '' |
disabled | boolean | false |
asChild | boolean | false |
| Shortcut | Description |
|---|---|
Tab | Moves focus into or out of the toggle group. |
ArrowRight | Moves focus to the next enabled item when orientation is horizontal. |
ArrowDown | Moves focus to the next enabled item when orientation is vertical. |
ArrowLeft | Moves focus to the previous enabled item when orientation is horizontal. |
ArrowUp | Moves focus to the previous enabled item when orientation is vertical. |
Home | Moves focus to the first enabled item. |
End | Moves focus to the last enabled item. |
Space | Toggles the focused item. |
Enter | Toggles the focused item. |
| Reference | What Rad UI follows |
|---|---|
Each item follows toggle button semantics with aria-pressed for the selected state. |