Import
import {
ToggleGroup ,
ToggleGroupItem
} from '@strongtie/design-system/toggle-group' ;
Usage
< ToggleGroup type = 'single' >
< ToggleGroupItem value = '1' > Toggle 1 </ ToggleGroupItem >
< ToggleGroupItem value = '2' > Toggle 2 </ ToggleGroupItem >
< ToggleGroupItem value = '3' > Toggle 3 </ ToggleGroupItem >
</ ToggleGroup >
<ToggleGroup> PropsChange the default rendered element for the one passed as a child, merging their props and behavior.
type
"single" | "multiple"
required
Determines the selection behavior. “single” allows only one selection at a time, “multiple” allows multiple selections.
value
string | string[]
default: "undefined"
The controlled value(s) of the toggle group. For single type, use string. For multiple type, use string array.
defaultValue
string | string[]
default: "undefined"
The default value(s) when the component is uncontrolled.
onValueChange
(value: string | string[]) => void
default: "undefined"
Callback fired when the value changes.
Whether the entire toggle group is disabled.
Whether to use roving tabindex for keyboard navigation.
orientation
"horizontal" | "vertical"
default: "undefined"
The orientation of the toggle group.
dir
"ltr" | "rtl"
default: "undefined"
The reading direction of the toggle group. If omitted, inherits globally or assumes LTR.
Whether keyboard navigation should loop from last to first item.
variant
"default" | "outline"
default: "\"default\""
The visual variant of the toggle buttons.
size
"sm" | "default" | "lg"
default: "\"default\""
The size of the toggle buttons.
<ToggleGroupItem> PropsChange the default rendered element for the one passed as a child, merging their props and behavior.
The unique value for this toggle item.
Whether this specific toggle item is disabled.
variant
"default" | "outline"
default: "inherited"
Override the variant for this specific item. Falls back to group variant.
size
"sm" | "default" | "lg"
default: "inherited"
Override the size for this specific item. Falls back to group size.
Styling Classes The component applies the following CSS classes:
toggle-group - Base toggle group container class
Toggle items inherit classes from the toggle component based on variant and size
Usage Examples Single Selection
Multiple Selection
Controlled
Different Sizes
Outline Variant
Disabled
Vertical Orientation
< ToggleGroup type = "single" defaultValue = "center" >
< ToggleGroupItem value = "left" > Left </ ToggleGroupItem >
< ToggleGroupItem value = "center" > Center </ ToggleGroupItem >
< ToggleGroupItem value = "right" > Right </ ToggleGroupItem >
</ ToggleGroup >
For more examples, visit the Storybook .