开关
用途
Add your switch HTML
Add class="input" and role="switch" to a native checkbox. Use a native <label> or aria-label for accessible naming.
HTML 结构
<input type="checkbox" role="switch" class="input">- The switch control. Use native checkbox state: add
checkedfor an initially enabled switch,disabledfor a disabled switch, andaria-invalid="true"for invalid state. data-size="sm"Optional- Renders the smaller switch size.
示例
说明
Focus is shared across devices, and turns off when you leave the app.
选择卡
Use a wrapping <label> when the whole card should toggle the switch.
已禁用
当周围字段应使用禁用样式时,将 disabled 添加到开关,将 data-disabled="true" 添加到字段包装器。
无效
将 aria-invalid="true" 添加到交换机,并将 data-invalid="true" 添加到字段包装器。
You must accept the terms and conditions to continue.
尺寸
使用data-size="sm"渲染较小的开关尺寸。
RTL
切换字段布局使用文档方向。在字段或祖先上设置 dir="rtl"。
يتم مشاركة التركيز عبر الأجهزة، ويتم إيقاف تشغيله عند مغادرة التطبيق.