Switch

On and off toggle on Radix Switch in default and small sizes.

Installation

pnpm dlx shadcn@latest add @ward/switch

Add the Ward registry to components.json once:

"registries": {
  "@ward": "https://ward.so/r/{name}.json"
}

Or install from the URL with no configuration: npx shadcn@latest add https://ward.so/r/switch.json

Usage

import { Switch } from "@/components/ui/switch";
<label className="flex items-center gap-2 text-sm">
  <Switch defaultChecked onCheckedChange={(on) => console.log(on)} />
  Email me about new releases
</label>

Props

PropTypeDefaultDescription
size"default" | "sm""default"Size of the track and thumb.
checkedboolean-Whether the switch is on, when the parent controls it.
defaultCheckedbooleanfalseWhether the switch starts on when it is uncontrolled.
onCheckedChange(checked: boolean) => void-Called when the switch is toggled.
disabledbooleanfalseDim the switch and stop it taking input.

Ward · Version 1.0.0 · Registry manifest