开关
在开启与关闭两种状态之间切换。
安装
Command
Manual
Use the JGuang UI Registry URL provided on /systems/jguang-ui#install.
安装以下依赖:
npm install radix-ui
将以下代码复制到你的项目中。
View complete source: components/ui/switch.tsx
根据项目配置更新导入路径。
用法
import { Switch } from "@/components/ui/switch"
<Switch />
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.
尺寸
Use the size prop to change the size of the switch.
从右到左布局
To enable RTL support in JGuang UI, see the RTL configuration guide.
API 参考
See the Radix Switch documentation.
来源: components/radix/switch.mdx
JGuang UI 技术文档。