All components
Switch
Every hand-drawn switch size and state.
Sizes
Checked
Invalid
Disabled
Installation
Add Switch with the shadcn CLI.
npx shadcn@latest add https://sketchcn.chuwii.com/r/switch.json
Examples
Settings rows and controlled switches.
Settings row
Redraw every outline with a hand-drawn wobble.
import { Switch } from "@/components/ui/switch";

export function SettingRow() {
  const id = useId();

  return (
    <div className="flex w-full items-center justify-between gap-4">
      <div className="flex flex-col">
        <label htmlFor={id} className="text-sm">
          Rough edges
        </label>
        <span className="text-muted-foreground text-xs">
          Redraw every outline with a hand-drawn wobble.
        </span>
      </div>
      <Switch id={id} defaultChecked />
    </div>
  );
}
Controlled
Autosave is on
import { Switch } from "@/components/ui/switch";

export function AutosaveToggle() {
  const [autosave, setAutosave] = useState(true);

  return (
    <div className="flex items-center gap-3">
      <Switch
        checked={autosave}
        onCheckedChange={setAutosave}
        aria-label="Autosave"
      />
      <span className="text-sm">
        Autosave is {autosave ? "on" : "off"}
      </span>
    </div>
  );
}