Files
shadcn-ui/apps/www/content/docs/primitives/switch.mdx
2023-01-24 19:51:29 +04:00

39 lines
817 B
Plaintext

---
title: Switch
description: A control that allows the user to toggle between checked and not checked.
radix:
link: https://www.radix-ui.com/docs/primitives/components/switch
api: https://www.radix-ui.com/docs/primitives/components/switch#api-reference
---
<ComponentExample src="/components/examples/switch/demo.tsx">
<SwitchDemo />
</ComponentExample>
## Installation
1. Install the `@radix-ui/react-switch` component from radix-ui:
```bash
npm install @radix-ui/react-switch
```
2. Copy and paste the following code into your project.
<ComponentSource src="/components/ui/switch.tsx" />
<Callout>
This is the `<Switch />` primitive. You can place it in a file at
`components/ui/switch.tsx`.
</Callout>
## Usage
```tsx
import { Switch } from "@/components/ui/switch"
```
```tsx
<Switch />
```