Switch
A component for displaying switches.
Usage Examples
Basic Usage
Use the Switch component for toggle actions
<Switch onCheckedChange={(checked) => console.log(checked)} />
With Label
Combine with label for better accessibility
<div className="flex items-center space-x-2">
<Switch id="airplane-mode" />
<Label htmlFor="airplane-mode">Airplane Mode</Label>
</div>
Props
Name
Type
Default
Description
checked
boolean
-
The controlled checked state
defaultChecked
boolean
false
The default checked state
onCheckedChange
(checked: boolean) => void
-
Called when the checked state changes