Toggle Group
A set of two-state buttons that can be toggled on or off.
Installation
pnpm dlx cubix@latest add toggle-groupUsage
import { ToggleGroup, ToggleGroupItem } from "@/components/cubix/toggle-group"<ToggleGroup>
<ToggleGroupItem value="a">A</ToggleGroupItem>
<ToggleGroupItem value="b">B</ToggleGroupItem>
<ToggleGroupItem value="c">C</ToggleGroupItem>
</ToggleGroup>Composition
Use the following composition to build a ToggleGroup:
ToggleGroup
├── ToggleGroupItem
└── ToggleGroupItemOutline
Use variant="outline" for an outline style.
Size
Use the size prop to change the size of the toggle group.
Spacing
Use spacing to control the gap between items. Default is 2. Use spacing=0 for connected items.
Vertical
Use orientation="vertical" for vertical toggle groups.
Disabled
Custom
A custom toggle group example.
Use font-normal to set the font weight.
RTL
Wrap the group in a container with dir="rtl" to mirror direction.
API Reference
See also the Base UI Toggle Group documentation for primitive props.
ToggleGroup
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "default" | "outline" | "default" | Visual style applied to all items unless overridden. |
| size | "default" | "sm" | "lg" | "default" | Size applied to all items unless overridden. |
| spacing | number | 2 | Gap between items. Use 0 for connected items with shared borders. |
| orientation | "horizontal" | "vertical" | "horizontal" | Layout orientation of the group. |
| multiple | boolean | false | When true, more than one item can be pressed (Base UI). Radix uses type="multiple". |
| value | string[] | - | Controlled pressed values. |
| defaultValue | string[] | - | Uncontrolled initial pressed values. |
| onValueChange | (value: string[]) => void | - | Called when the pressed values change. |
| disabled | boolean | false | When true, interaction is disabled for the group. |
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |
ToggleGroupItem
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | - | Unique value for this item within the group. |
| variant | "default" | "outline" | - | Overrides the group variant for this item. |
| size | "default" | "sm" | "lg" | - | Overrides the group size for this item. |
| disabled | boolean | false | When true, this item cannot be pressed. |
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |