mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-07-01 16:44:24 +00:00
59 lines
833 B
Plaintext
59 lines
833 B
Plaintext
---
|
|
title: Toggle
|
|
description: A two-state button that can be either on or off.
|
|
component: true
|
|
radix:
|
|
link: https://www.radix-ui.com/docs/primitives/components/toggle
|
|
api: https://www.radix-ui.com/docs/primitives/components/toggle#api-reference
|
|
---
|
|
|
|
<ComponentPreview name="toggle-demo" />
|
|
|
|
## Installation
|
|
|
|
<Steps>
|
|
|
|
### Command
|
|
|
|
```bash
|
|
npx shadcn-ui add toggle
|
|
```
|
|
|
|
### Usage
|
|
|
|
```tsx
|
|
import { Toggle } from "@/components/ui/toggle"
|
|
```
|
|
|
|
```tsx
|
|
<Toggle>Toggle</Toggle>
|
|
```
|
|
|
|
</Steps>
|
|
|
|
## Examples
|
|
|
|
### Default
|
|
|
|
<ComponentPreview name="toggle-demo" />
|
|
|
|
### Outline
|
|
|
|
<ComponentPreview name="toggle-outline" />
|
|
|
|
### With Text
|
|
|
|
<ComponentPreview name="toggle-with-text" />
|
|
|
|
### Small
|
|
|
|
<ComponentPreview name="toggle-sm" />
|
|
|
|
### Large
|
|
|
|
<ComponentPreview name="toggle-lg" />
|
|
|
|
### Disabled
|
|
|
|
<ComponentPreview name="toggle-disabled" />
|