Getting Started
Foundations
Components
#Installation
npx @dinachi/cli@latest add switch#Usage
tsx
import { Switch, SwitchThumb } from "@/components/ui/switch"#Examples
Default Switch
A basic switch toggle
Controlled Switch
Switch with controlled state and status display
Status: Disabled
Switch States
Switches in different states including disabled
#API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
| checked | boolean | — | The controlled checked state. |
| defaultChecked | boolean | false | The initial checked state when uncontrolled. |
| onCheckedChange | (checked: boolean) => void | — | Callback fired when checked state changes. |
| disabled | boolean | false | Disables the switch. |
| required | boolean | false | Marks the switch as required in a form. |