Switch
Turn a setting on or off, taking effect right away.
Receive notifications about this project.
When to use it
Use Switch for settings that apply the moment they change, such as notifications or dark mode. Label it with the setting, not the action.
Inside a form that people save at the end, use Checkbox, so nothing seems to happen before they submit.
SwitchThis page
Takes effect now.
Receive notifications about this project.
Preferences that apply at once.
How it behaves
Use checked/onCheckedChange or defaultChecked. Base UI exposes native form input semantics through name.
Pair it with a visible label. Space toggles the switch; disabled controls are unavailable to interaction.
Pointer changes use a brief thumb transition. Keyboard changes and reduced-motion changes are immediate.
Build it
Add it with the shadcn CLI:
1pnpm dlx shadcn@latest add https://jzbui.com/r/switch.jsonA complete example. Change the values to fit your product:
1234import { Switch } from "@/components/ui/switch"
<label htmlFor="notifications">Project updates</label><Switch id="notifications" name="notifications" defaultChecked />The full source is yours to edit once installed: