Toggle Group

A set of two-state buttons that can be toggled on or off, built on top of Base UI.

Installation

$ npx shadcn@latest add "/r/toggle-group.json"

Usage

Sizes

Available in three sizes to accommodate different layouts.

Props

ToggleGroup

PropTypeDefaultDescription
size"sm" | "md" | "lg""md"The size of the toggle group items.
type"single" | "multiple""single"Whether the group allows single or multiple selection.
valuestring | string[]-The controlled value of the toggle group.
defaultValuestring | string[]-The default value of the toggle group.
onValueChange(value: any) => void-Event handler called when the value changes.
disabledbooleanfalseWhether the toggle group is disabled.
classNamestring-Additional CSS classes to apply to the toggle group.

ToggleGroupItem

PropTypeDefaultDescription
valuestring-The value of the toggle group item.
disabledbooleanfalseWhether the toggle group item is disabled.
classNamestring-Additional CSS classes to apply to the item.