Toggle Group
A group of toggle buttons that supports single or multiple selection, ideal for layout view switching and toolbar options.
Preview
Single Selection
Multiple Selection
Usage
tsx
import { ToggleGroup, ToggleGroupItem } from "zostel-ui";
{/* Single selection */}
<ToggleGroup type="single" defaultValue="grid">
<ToggleGroupItem value="grid" aria-label="Grid view">
<Grid className="h-4 w-4" />
</ToggleGroupItem>
<ToggleGroupItem value="list" aria-label="List view">
<List className="h-4 w-4" />
</ToggleGroupItem>
<ToggleGroupItem value="columns" aria-label="Columns view">
<Columns className="h-4 w-4" />
</ToggleGroupItem>
</ToggleGroup>
{/* Multiple selection */}
<ToggleGroup type="multiple">
<ToggleGroupItem value="bold">
<Bold className="h-4 w-4" />
</ToggleGroupItem>
<ToggleGroupItem value="italic">
<Italic className="h-4 w-4" />
</ToggleGroupItem>
</ToggleGroup>Props
| Prop | Type | Default | Description |
|---|---|---|---|
type | "single" | "multiple" | — | Whether a single or multiple items can be pressed at a time. |
value | string | string[] | — | The controlled value(s) of the pressed item(s). |
defaultValue | string | string[] | — | The default value(s) of the pressed item(s). |
onValueChange | (value: string | string[]) => void | — | Callback fired when the value changes. |
variant | "default" | "outline" | "default" | Visual style variant of the toggle group items. |
size | "default" | "sm" | "lg" | "default" | Size of the toggle group buttons. |
disabled | boolean | false | When true, prevents interaction with all items. |
typeType:
"single" | "multiple"Default: —
Whether a single or multiple items can be pressed at a time.
valueType:
string | string[]Default: —
The controlled value(s) of the pressed item(s).
defaultValueType:
string | string[]Default: —
The default value(s) of the pressed item(s).
onValueChangeType:
(value: string | string[]) => voidDefault: —
Callback fired when the value changes.
variantType:
"default" | "outline"Default: "default"
Visual style variant of the toggle group items.
sizeType:
"default" | "sm" | "lg"Default: "default"
Size of the toggle group buttons.
disabledType:
booleanDefault: false
When true, prevents interaction with all items.