ComponentClient component

Switch

An accessible, animated control for toggling a boolean setting.

Installation

Preview

Product updates

Occasional release notes.

Usage insights

A weekly digest.

Usage

tsx
import { Switch } from "@/components/ui/switch"

export function SwitchDemo() {
  return <Switch aria-label="Enable notifications" defaultChecked />
}

API reference

PropTypeDefaultDescription
checkedbooleanControlled checked state.
defaultCheckedbooleanfalseInitial state when uncontrolled.
onCheckedChange(checked: boolean) => voidRuns whenever the state changes.
disabledbooleanfalsePrevents interaction.