Copy to clipboard
Installation
Copy to clipboard
npx bearnie add toggle-group
npx bearnie add toggle-group
bunx bearnie add toggle-group
bunx bearnie add toggle-group
pnpm dlx bearnie add toggle-group
pnpm dlx bearnie add toggle-group
yarn dlx bearnie add toggle-group
yarn dlx bearnie add toggle-group
Copy to clipboard
import ToggleGroup from "@/components/ui/toggle/ToggleGroup.astro";
import ToggleGroupItem from "@/components/ui/toggle/ToggleGroupItem.astro";
Usage
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle"
<ToggleGroup type="single">
<ToggleGroupItem value="a">A</ToggleGroupItem>
<ToggleGroupItem value="b">B</ToggleGroupItem>
<ToggleGroupItem value="c">C</ToggleGroupItem>
</ToggleGroup>
Examples
Outline
Copy to clipboard
Multiple
Copy to clipboard
Sizes
Copy to clipboard
Vertical
Copy to clipboard
Disabled
Copy to clipboard
Anatomy
ToggleGroup- Container that manages toggle stateToggleGroupItem- Individual toggle button within the group
Props
ToggleGroup
| Prop | Type | Default | Description |
|---|---|---|---|
| type | ”single” | “multiple" | "single” | Whether single or multiple items can be pressed |
| variant | ”default” | “outline" | "default” | Visual style variant |
| size | ”sm” | “default” | “lg" | "default” | Size of the toggle items |
| orientation | ”horizontal” | “vertical" | "horizontal” | Layout orientation |
| defaultValue | string | string[] | - | Default pressed value(s) |
| disabled | boolean | false | Disables all items in the group |
| class | string | - | Additional CSS classes |
ToggleGroupItem
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | - | Unique value for the item (required) |
| disabled | boolean | false | Disables the toggle item |
| class | string | - | Additional CSS classes |