Switch
Inputshadcn/uiTurns a setting on or off with immediate effect, like 'Notifications' or 'Face ID'.
When to use
- Use it in settings lists as the trailing element of a ListItem.
- Apply the change at once, without a Save button.
- Don't use it in forms that are submitted later; use Checkbox.
- Don't label it with on/off text; the label names the setting.
Accessibility
- Role
- switch
- Keyboard
- Space and Enter toggle.
- Notes
- Link it to its label with aria-labelledby or a Label htmlFor.
Props
checked / onCheckedChangeboolean / (checked: boolean) => voidControlled state.
Prompt for your agent
Use the UnbuiltUI Switch. Call unbuilt_get_component("Switch") first and follow its spec: variants, states, usage rules and accessibility.
unbuilt_get_component returns
0 variants4 states1 prop4 usage rules2 a11y notes5 tokens1 example
Add it with shadcn
$
npx shadcn add https://unbuiltui.com/r/switch.jsonTokens · 5
accent.defaultborder.defaultbg.raisedborder.focusshadow.raised