Switch
A control that allows the user to toggle between checked and not checked.
Preview
Installation
Use the CLI to add this component to your project.
Usage
tsx
5 linesCopy
Examples
With Label
Disabled
Settings Form
Receive push notifications
Play notification sounds
Share usage data
On Success Color
Blue
Red
Green
Purple
Orange
Props
| Prop | Type | Default | Description |
|---|---|---|---|
checked | boolean | Controlled checked state | |
onSuccessColor | 'red' | 'blue' | 'green' | 'purple' | 'orange' | 'default' | default | Color of the switch when checked |
defaultChecked | boolean | false | Default checked state |
onCheckedChange | (checked: boolean) => void | Called when checked state changes | |
disabled | boolean | false | Disable the switch |