# Switch

> Toggle switch with two sizes.

Registry name: `switch`. HTML docs: https://ui.anuragroy.dev/component/switch.

## Install

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

If the website is down: `npx shadcn@latest add https://raw.githubusercontent.com/anurag-roy/ui.anuragroy.dev/main/public/r/switch.json`.

Registry JSON: https://ui.anuragroy.dev/r/switch.json (GitHub: https://raw.githubusercontent.com/anurag-roy/ui.anuragroy.dev/main/public/r/switch.json).

## Import

Import paths follow the consumer `components.json` aliases. After a default install:

```tsx
import { Switch } from "@/components/ui/switch"
```

## Usage

```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

### Switch

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

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | "sm" \| "default" | "default" |  |

## See also

- [HTML page](https://ui.anuragroy.dev/component/switch): Preview and the same docs in the site chrome.
- [Registry item](https://ui.anuragroy.dev/r/switch.json): Source files and dependencies.
- [Catalog](https://ui.anuragroy.dev/component): All components.
- [llms.txt](https://ui.anuragroy.dev/llms.txt): Agent index for this library.
