Toggle Group

Toggles in a row: one of several, or any number with multiple.

@cupertinoui/toggle-groupBase UI Toggle Group Registry JSON

Installation

pnpm dlx shadcn@latest add @cupertinoui/toggle-group

The first install also adds the macOS theme. See Installation to set up the registry.

Usage

import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"

<ToggleGroup variant="outline" spacing={0} defaultValue={["left"]}>
  <ToggleGroupItem value="left"><AlignLeftIcon /></ToggleGroupItem>
  <ToggleGroupItem value="center"><AlignCenterIcon /></ToggleGroupItem>
</ToggleGroup>

API Reference

Every part forwards the props of the underlying Base UI Toggle Group part. The props below are the ones CupertinoUI adds or changes.

ToggleGroup

PropTypeDescription
value / defaultValuestring[]The values of the pressed items.
multipleboolean
Default: false
Lets several items be pressed.
spacingnumber
Default: 1
The gap between items; 0 joins them into one control.
variant / sizePassed on to every item, as on Toggle.
classNamestringExtra classes, merged with the component's own.