Skip to content

Browse components

← All components

Switch

Toggle switch with two sizes.

Install
npx shadcn@latest add https://ui.anuragroy.dev/r/switch.json

Preview

Loading preview…

Installation

Add the component from this site. The shadcn CLI fetches the registry JSON over HTTPS — no named registry submission required.

Terminal
npx shadcn@latest add https://ui.anuragroy.dev/r/switch.json

GitHub fallback if the website is down:

Terminal
npx shadcn@latest add https://raw.githubusercontent.com/anurag-roy/ui.anuragroy.dev/main/public/r/switch.json

Usage

Import paths follow your components.json aliases. After install, the default path is @/components/ui/switch.

Import
import { Switch } from "@/components/ui/switch"
example.tsx
import { Switch } from "@/components/ui/switch"export function Example() {  return (    <label className="flex items-center gap-2 text-sm">      <Switch defaultChecked /> Enable notifications    </label>  )}

API Reference

Switch

Base UI Switch. Use `checked` / `defaultChecked` / `onCheckedChange`.

PropTypeDefault
size"sm" | "default""default"