---
title: "Switch"
description: "A switch for on and off settings, with keyboard support and form integration. Built on Base UI."
plan: Free
docs: https://ui.edbn.me/docs/components/switch
---

# Switch

A switch for on and off settings, with keyboard support and form integration. Built on Base UI.

## Installation

```bash
npx shadcn@4.19.0 add https://ui.edbn.me/r/switch.json
```

## Dependencies
- npm: @base-ui/react@^1.8.0
- edbn: edbn-base

## Usage

```tsx examples/switch-basic.tsx
"use client";
import { Label } from "@/components/ui/label";
import { Switch } from "@/components/ui/switch";

export default function SwitchBasicPreview() {
  return (
    <div className="flex items-center gap-2">
      <Switch id="airplane" />
      <Label htmlFor="airplane">Airplane mode</Label>
    </div>
  );
}
```

## Files
- components/ui/switch.tsx (33 lines)

## For agents
- Base theme, once per project: npx shadcn@4.19.0 add https://ui.edbn.me/r/edbn-base.json
- MCP server with search, items, examples and source: https://ui.edbn.me/mcp
- Every page and item: https://ui.edbn.me/llms.txt
