---
title: Switch
description: A control that allows the user to toggle between checked and not checked.
base: base
component: true
links:
doc: https://base-ui.com/react/components/switch
api: https://base-ui.com/react/components/switch#api-reference
---
## Installation
Command
Manual
```bash
npx shadcn@latest add switch
```
Install the following dependencies:
```bash
npm install @base-ui/react
```
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Usage
```tsx
import { Switch } from "@/components/ui/switch"
```
```tsx
```
## Examples
### Description
### Choice Card
Card-style selection where `FieldLabel` wraps the entire `Field` for a clickable card pattern.
### Disabled
Add the `disabled` prop to the `Switch` component to disable the switch. Add the `data-disabled` prop to the `Field` component for styling.
### Invalid
Add the `aria-invalid` prop to the `Switch` component to indicate an invalid state. Add the `data-invalid` prop to the `Field` component for styling.
### Size
Use the `size` prop to change the size of the switch.
## RTL
To enable RTL support in shadcn/ui, see the [RTL configuration guide](/docs/rtl).
## API Reference
See the [Base UI Switch](https://base-ui.com/react/components/switch#api-reference) documentation.