Switch
On or off, and it happens now.
Default
One on, one off. Space flips the focused switch.
Use a switch when the change takes effect the moment it is flipped, and a checkbox when it only counts once the form is submitted. That is the whole difference, and readers feel it.
Installation
npx philcn@latest add switchThe file is written into your project. It is yours from then on — change it as you like.
Props
| Prop | Type | What it does |
|---|---|---|
| Switch.checked | boolean | Controlled: on or off. |
| Switch.defaultChecked | boolean | Uncontrolled: how it starts. |
| Switch.onCheckedChange | ((checked: boolean) => void) | Called with the new state on every flip. |
| Switch.disabled | boolean | Out of reach, and out of the tab order. |
Types are read from the library itself, so this table cannot describe an option the code no longer has.