Toggle

A button that stays pressed, like Bold in a format bar.

Installation

pnpm dlx shadcn@latest add @cupertinoui/toggle

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

Usage

import { Toggle } from "@/components/ui/toggle"

<Toggle aria-label="Bold">
  <BoldIcon />
</Toggle>

API Reference

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

Toggle

PropTypeDescription
variant"default" | "outline"
Default: "default"
Borderless, or a bordered button.
size"sm" | "default" | "lg"
Default: "default"
20, 24 or 28pt tall.
pressed / defaultPressedbooleanWhether it is on.
onPressedChange(pressed: boolean) => voidCalled when it turns on or off.
classNamestringExtra classes, merged with the component's own.