Toggle Group
Set of toggles with single or multiple selection.
Installation
bun add @xerobi/ui
import { ToggleGroup, ToggleGroupItem } from "@xerobi/ui/toggle-group"This component is client-side. In Astro, hydrate it with a client directive.
Examples
Default
import { AlignCenterIcon, AlignLeftIcon, AlignRightIcon } from "lucide-react"
import { ToggleGroup, ToggleGroupItem } from "@xerobi/ui/toggle-group"
export function ToggleGroupDefault() {
return (
<ToggleGroup defaultValue={["left"]}>
<ToggleGroupItem value="left" aria-label="Align left"><AlignLeftIcon /></ToggleGroupItem>
<ToggleGroupItem value="center" aria-label="Align center"><AlignCenterIcon /></ToggleGroupItem>
<ToggleGroupItem value="right" aria-label="Align right"><AlignRightIcon /></ToggleGroupItem>
</ToggleGroup>
)
}API reference
ToggleGroup
Also accepts every prop of Base UI ToggleGroup.
| Prop | Type | Description |
|---|---|---|
| orientation | "horizontal" | "vertical" | |
| variant | "default" | "outline" | |
| size | "default" | "sm" | "lg" | |
| spacing | number |
ToggleGroupItem
Also accepts every prop of Base UI Toggle.
| Prop | Type | Description |
|---|---|---|
| variant | "default" | "outline" | |
| size | "default" | "sm" | "lg" |
Styling hooks: [data-slot="toggle-group"], [data-slot="toggle-group-item"].