ThiloDesign System
DV

Switch

shadcn/ui

Toggle for binary on/off settings. Always pair with a Label using htmlFor.

@/components/ui/switch

States

StatePreviewToken
Off
bg-input border-input
On
bg-primary
Focus
ring-ring/50 — Tab to see
Disabled off
opacity-50 cursor-not-allowed
Disabled on
opacity-50 cursor-not-allowed

In context — notification settings

Notifications
3 active

Label left, Switch right — standard settings panel layout

Switch vs Checkbox

SwitchCheckbox
EffectImmediate — applies on toggleDeferred — requires form submit
ContextSettings, preferences, feature flagsForms, multi-select, terms
IndeterminateNot supportedchecked="indeterminate" supported

Props

PropTypeDescription
checkedbooleanControlled on/off state
defaultCheckedbooleanInitial state (uncontrolled)
onCheckedChangefunction(checked: boolean) => void
disabledbooleanPrevents interaction, reduces opacity
idstringLinks to <Label htmlFor> for accessibility

On this page