A set of two-state buttons that can be toggled on or off.
Multi-selection toggle group.
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group" import { Bold, Italic, Underline } from "lucide-react" export function ToggleGroupDemo() { return ( <ToggleGroup type="multiple"> <ToggleGroupItem value="bold" aria-label="Toggle bold"> <Bold className="h-4 w-4" /> </ToggleGroupItem> <ToggleGroupItem value="italic" aria-label="Toggle italic"> <Italic className="h-4 w-4" /> </ToggleGroupItem> <ToggleGroupItem value="underline" aria-label="Toggle underline"> <Underline className="h-4 w-4" /> </ToggleGroupItem> </ToggleGroup> ) }
Prop | Type | Default | Description |
---|---|---|---|
type | single | multiple | - | Whether a single or multiple items can be selected. |
value | string | string[] | - | The controlled value of the item(s) to select. |
defaultValue | string | string[] | - | The value of the item(s) to select by default. |
onValueChange | function | - | Event handler called when the value changes. |
variant | default | outline | default | The visual style of the toggle group. |
size | sm | default | lg | default | The size of the toggle group items. |