# 切换按钮 · JGuang UI

> 在按下与未按下状态之间切换。

- 页面: https://jiguang132.com/zh/systems/jguang-ui/docs/components/radix/toggle
- 改编自: shadcn/ui 文档 (MIT) @ bc0705384b51252af26dcc65425b216bf5eb063c
- 说明：正文保留英文原文。

> 示例 `toggle-demo`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/radix/toggle


## Installation


  

**Command**


  

**Manual**


```text
Use the JGuang UI Registry URL provided on /systems/jguang-ui#install.
```


### Install the following dependencies:


```bash
npm install radix-ui
```


### Copy and paste the following code into your project.


[View complete source: components/ui/toggle.tsx](/r/jguang-ui/radix/toggle.json)


### Update the import paths to match your project setup.


## Usage

```tsx
import { Toggle } from "@/components/ui/toggle"
```

```tsx
<Toggle>Toggle</Toggle>
```

## Outline

Use `variant="outline"` for an outline style.


> 示例 `toggle-outline`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/radix/toggle


## With Text


> 示例 `toggle-text`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/radix/toggle


## Size

Use the `size` prop to change the size of the toggle.


> 示例 `toggle-sizes`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/radix/toggle


## Disabled


> 示例 `toggle-disabled`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/radix/toggle


## RTL

To enable RTL support in JGuang UI, see the [RTL configuration guide](/systems/jguang-ui/docs/rtl).


> 示例 `toggle-rtl`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/radix/toggle


## API Reference

See the [Radix Toggle](https://www.radix-ui.com/docs/primitives/components/toggle#api-reference) documentation.

---

JGuang 全部资源索引: https://jiguang132.com/llms.txt
