# Switch · JGuang UI

> A control that allows the user to toggle between checked and not checked.

- Page: https://jiguang132.com/systems/jguang-ui/docs/components/radix/switch
- Based on: shadcn/ui documentation (MIT) @ bc0705384b51252af26dcc65425b216bf5eb063c

> Example `switch-demo`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/switch


## 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/switch.tsx](/r/jguang-ui/radix/switch.json)


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


## Usage

```tsx
import { Switch } from "@/components/ui/switch"
```

```tsx
<Switch />
```

## Description


> Example `switch-description`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/switch


## Choice Card

Card-style selection where `FieldLabel` wraps the entire `Field` for a clickable card pattern.


> Example `switch-choice-card`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/switch


## Disabled

Add the `disabled` prop to the `Switch` component to disable the switch. Add the `data-disabled` prop to the `Field` component for styling.


> Example `switch-disabled`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/switch


## 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.


> Example `switch-invalid`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/switch


## Size

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


> Example `switch-sizes`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/switch


## RTL

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


> Example `switch-rtl`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/switch


## API Reference

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

---

Index of all JGuang resources: https://jiguang132.com/llms.txt
