Components › Actions
Toggle group
A set of toggles on one tray: one on at a time, or several. Arrow keys move between them.
Installation
npx plankui@latest add toggle-groupUsage
import { ToggleGroup } from "@/components/ui/toggle-group";
<ToggleGroup type="single" value={align} onValueChange={setAlign} aria-label="Alignment">
<ToggleGroupItem value="left" aria-label="Align left"><AlignLeftIcon /></ToggleGroupItem>
<ToggleGroupItem value="center" aria-label="Align centre"><AlignCenterIcon /></ToggleGroupItem>
</ToggleGroup>API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| type | "single" | "multiple" | required | One item on at a time, or any number. |
| value / defaultValue | string | string[] | A string for single, an array for multiple. | |
| onValueChange | (value) => void | Called when an item turns on or off. | |
| variant / size | "ghost" | "outline", "sm" | "md" | "lg" | "ghost", "sm" | The look of every item, the same as Toggle. |