Duostrap Checkbox
基于 Base Checkbox 的 Duostrap 自定义复选框组件,支持选中、半选、受控与列表组合。
Duostrap Checkbox 采用自定义 Root / Indicator 结构来呈现 Duostrap 经典的 14px 斜面渐变控件与蓝色聚焦光晕,不依赖旧版 Bootstrap JavaScript 或 Glyphicons。
Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<div class="flex items-center gap-3">
<wc-duostrap-checkbox-root default-checked>
<wc-duostrap-checkbox-indicator></wc-duostrap-checkbox-indicator>
</wc-duostrap-checkbox-root>
<wc-duostrap-label-root>
Accept terms and conditions
</wc-duostrap-label-root>
</div>将于 0.3.0-rc.1 及后续版本中提供。查看已实现的子集。
import { DuostrapCheckboxIndicator, DuostrapCheckboxRoot, DuostrapLabelRoot,} from '@proto.ui/prototypes-duostrap';
export function Example() { return ( <div className="flex items-center gap-2.5"> <DuostrapCheckboxRoot defaultChecked> <DuostrapCheckboxIndicator /> </DuostrapCheckboxRoot> <DuostrapLabelRoot>Accept terms and conditions</DuostrapLabelRoot> </div> );}- 状态由 Root 统一管理:支持受控与非受控
checked、indeterminate,处理指针与Space键激活、禁用、只读、焦点以及带mixed状态的checkbox无障碍角色。 - Indicator:放置在
Root内部,自动根据所属Root状态显示深色勾号或横线;同时为半选和选中时优先显示半选横线。 - 经典视觉反馈:悬停与按压延续 Duostrap 斜面渐变响应,聚焦时显示
#52a8ec蓝色外光晕,并在深色页面中保持经典的浅色控件配色。
Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<div class="flex items-center gap-3">
<wc-duostrap-checkbox-root default-checked>
<wc-duostrap-checkbox-indicator></wc-duostrap-checkbox-indicator>
</wc-duostrap-checkbox-root>
<wc-duostrap-label-root>
Accept terms and conditions
</wc-duostrap-label-root>
</div> Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<div class="flex items-center gap-3">
<wc-duostrap-checkbox-root disabled>
<wc-duostrap-checkbox-indicator></wc-duostrap-checkbox-indicator>
</wc-duostrap-checkbox-root>
<wc-duostrap-label-root>
Enable notifications
</wc-duostrap-label-root>
</div> Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<div class="flex items-center gap-3">
<wc-duostrap-checkbox-root indeterminate>
<wc-duostrap-checkbox-indicator></wc-duostrap-checkbox-indicator>
</wc-duostrap-checkbox-root>
<wc-duostrap-label-root>
Sync workspace preferences
</wc-duostrap-label-root>
</div> Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<div class="flex items-center gap-3">
<wc-duostrap-checkbox-root default-checked>
<wc-duostrap-checkbox-indicator></wc-duostrap-checkbox-indicator>
</wc-duostrap-checkbox-root>
<wc-duostrap-label-root>Hard disks</wc-duostrap-label-root>
</div> Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<div class="flex items-center gap-3">
<wc-duostrap-checkbox-root indeterminate>
<wc-duostrap-checkbox-indicator></wc-duostrap-checkbox-indicator>
</wc-duostrap-checkbox-root>
<wc-duostrap-label-root>Select all rows</wc-duostrap-label-root>
</div>| 属性 | 类型 | 默认值 |
|---|---|---|
checked | boolean undefined | 非受控 |
defaultChecked | boolean | false |
indeterminate | boolean undefined | 非受控 |
defaultIndeterminate | boolean | false |
disabled | boolean | false |
readOnly | boolean | false |
required | boolean | false |
Root 暴露 checked、indeterminate、disabled、readOnly、required、hovered、focused、focusVisible、pressed 状态,focusSelf(options?) 与 resetValue() 方法,以及 checkedChange({ checked, indeterminate })与 indeterminateChange({ indeterminate })事件。
Indicator
Section titled “Indicator”Indicator 不声明额外属性,放置在 Root 内部自动同步勾选与半选图标,暴露 checked、indeterminate、isChecked() 与 isIndeterminate()。