Dither / components
Switch
An instant on/off setting. Checked in the brand indigo.
- Stable
- 16 variants
- 8 props
- Light & Dark
light
dark
Code
import { Switch } from "@/components/ui/switch";export default function SwitchDemo() { return ( <div className="grid w-full max-w-sm gap-4"> <Switch label="Airplane mode" defaultChecked /> <Switch label="Small" size="sm" /> <Switch label="Share across devices" description="Focus is shared across devices, and turns off when you leave the app." placement="end" /> <Switch label="Accept terms and conditions" description="You must accept the terms to continue." invalid /> <Switch label="Disabled" disabled /> </div> );}Installation
npx shadcn add @dither/switchUsage
import { Switch } from "@/components/ui/switch";
<Switch label="Airplane mode" />Guidelines
- Use for settings that apply immediately. If a Save button is needed, use a Checkbox.
- The label says what is on ("Sound"), not the action ("Turn on sound").
- Checked uses the brand colour; never rely on colour alone (the thumb position also changes).
Props
Prop
Type
Examples
Box
light
dark
Code
import { Switch } from "@/components/ui/switch";export default function SwitchBox() { return ( <div className="grid w-full max-w-sm gap-2"> <Switch variant="box" placement="end" label="Share across devices" description="Focus is shared across devices." /> <Switch variant="box" placement="end" label="Notifications" description="Receive notifications when focus mode is on." defaultChecked /> </div> );}