Plinth

Switch

Toggle switch in two sizes.

Install

npx shadcn@latest add https://plinth.dhrumilkherde.com/r/switch.json

Usage

import { Switch } from "@/components/ui/switch";

<Switch checked={enabled} onCheckedChange={setEnabled} />

Use a switch for settings that apply immediately; use a Checkbox inside forms that submit.

Props

PropTypeDefault
sizesm · mdmd
checked / defaultCheckedboolean
onCheckedChange(checked, details) => void
disabledbooleanfalse

Accessibility

  • Base UI Switch: role="switch", toggles with Space and Enter, state in aria-checked.
  • Label it: htmlFor/id with a visible Label, or aria-label when the context makes text redundant.

On this page