Getting Started
Foundations
Integrations
Components
#Installation
npx @dinachi/cli@latest add switch#Usage
tsx
import { Switch, SwitchThumb } from "@/components/ui/switch"#Examples
#API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
| checked | boolean | — | The controlled checked state |
| defaultChecked | boolean | false | The initial checked state when uncontrolled |
| onCheckedChange | (checked: boolean, details: object) => void | — | Callback fired when checked state changes |
| name | string | — | Identifies the field when a form is submitted |
| value | string | — | Value submitted when switch is on (defaults to 'on') |
| disabled | boolean | false | Disables the switch |
| readOnly | boolean | false | Prevents activation and deactivation |
| required | boolean | false | Marks the switch as required in a form |