Skip to content

Checkbox

Used for selecting multiple items from a set of options.

Component Type

Basic Usage

Use v-model to bind the selected state.

html
<wd-checkbox v-model="value" shape="square">Checkbox</wd-checkbox>

Checkbox Group

Use wd-checkbox-group to manage multiple checkboxes.

html
<wd-checkbox-group v-model="value">
  <wd-checkbox value="1">Option 1</wd-checkbox>
  <wd-checkbox value="2">Option 2</wd-checkbox>
  <wd-checkbox value="3">Option 3</wd-checkbox>
</wd-checkbox-group>

Component State

Disabled

Set disabled to disable the checkbox.

html
<wd-checkbox-group v-model="value">
  <wd-checkbox value="1" disabled>Option 1</wd-checkbox>
  <wd-checkbox value="2">Option 2</wd-checkbox>
</wd-checkbox-group>

Indeterminate State

Set indeterminate to display an indeterminate state.

html
<wd-checkbox v-model="value" indeterminate>Indeterminate</wd-checkbox>

Component Variant

Shape

Set shape to change the checkbox shape, supports circle and square.

html
<wd-checkbox-group v-model="value">
  <wd-checkbox value="1" shape="square">Square</wd-checkbox>
  <wd-checkbox value="2" shape="circle">Circle</wd-checkbox>
</wd-checkbox-group>

Size

Set size to change the checkbox size, supports small and large.

html
<wd-checkbox-group v-model="value">
  <wd-checkbox value="1" size="small">Small</wd-checkbox>
  <wd-checkbox value="2" size="medium">Medium</wd-checkbox>
  <wd-checkbox value="3" size="large">Large</wd-checkbox>
</wd-checkbox-group>

Component Style

Max Selection Limit

Set max to limit the maximum number of selections.

html
<wd-checkbox-group v-model="value" :max="2">
  <wd-checkbox value="1">Option 1</wd-checkbox>
  <wd-checkbox value="2">Option 2</wd-checkbox>
  <wd-checkbox value="3">Option 3</wd-checkbox>
</wd-checkbox-group>

Inline Display

Set inline to display checkboxes in a row.

html
<wd-checkbox-group v-model="value" inline>
  <wd-checkbox value="1">Option 1</wd-checkbox>
  <wd-checkbox value="2">Option 2</wd-checkbox>
  <wd-checkbox value="3">Option 3</wd-checkbox>
</wd-checkbox-group>

Special Style

Checkbox Button

Set type="button" to display checkboxes as buttons.

html
<wd-checkbox-group v-model="value" type="button">
  <wd-checkbox value="1">Option 1</wd-checkbox>
  <wd-checkbox value="2">Option 2</wd-checkbox>
  <wd-checkbox value="3">Option 3</wd-checkbox>
</wd-checkbox-group>

Cell Style

Set cell to display checkboxes in cell style.

html
<wd-checkbox-group v-model="value" cell>
  <wd-checkbox value="1">Option 1</wd-checkbox>
  <wd-checkbox value="2">Option 2</wd-checkbox>
  <wd-checkbox value="3">Option 3</wd-checkbox>
</wd-checkbox-group>

Attributes

Checkbox Attributes

ParameterDescriptionTypeDefault Value
v-modelBinding valuebooleanfalse
valueCheckbox valuestring | number | boolean-
shapeCheckbox shape, supports circle, square, buttonstringcircle
sizeCheckbox size, supports small, medium, largestringmedium
checked-colorChecked colorstring-
disabledWhether disabledbooleanfalse
indeterminateWhether indeterminatebooleanfalse
max-widthMaximum widthstring | number-
custom-classRoot node custom class namestring-
custom-styleRoot node custom stylestring-

CheckboxGroup Attributes

ParameterDescriptionTypeDefault Value
v-modelBinding valueArray<string | number | boolean>[]
shapeCheckbox shape, supports circle, square, buttonstringcircle
sizeCheckbox size, supports small, medium, largestringmedium
checked-colorChecked colorstring-
disabledWhether disabledbooleanfalse
maxMaximum number of selectionsnumber-
inlineWhether inline displaybooleanfalse
cellWhether cell stylebooleanfalse
custom-classRoot node custom class namestring-
custom-styleRoot node custom stylestring-

Events

Checkbox Events

Event NameDescriptionParameters
changeTriggered when value changesvalue: boolean

CheckboxGroup Events

Event NameDescriptionParameters
changeTriggered when value changesvalue: Array<string | number | boolean>

Slots

Checkbox Slots

nameDescription
defaultCheckbox label content

CheckboxGroup Slots

nameDescription
defaultCheckbox list

主题定制

CSS 变量

组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 ConfigProvider 全局配置

名称默认值描述
--wot-checkbox-label-margin$spacing-tight-
--wot-checkbox-color-checked$primary-6文字与图标距离
--wot-checkbox-icon-size$n-22选中颜色
--wot-checkbox-unchecked-color$coolgrey-3图标尺寸
--wot-checkbox-label-font-size$typography-body-size-main未选中图标颜色
--wot-checkbox-label-color$text-main文字字号
--wot-checkbox-label-line-height$typography-body-line--height-size-main文字颜色
--wot-checkbox-opacity-disabled$opacity-disabled文字行高
--wot-checkbox-horizontal-margin$spacing-zero $spacing-extra-loose $spacing-zero $spacing-zero禁用态透明度
--wot-checkbox-button-margin$spacing-zero $spacing-extra-loose $spacing-extra-loose $spacing-zero水平模式多个单选框距离
--wot-checkbox-button-border-width$stroke-main按钮模式多个单选框距离
--wot-checkbox-button-shape-border-radius$radius-radius-full边框宽度
--wot-checkbox-button-shape-size$n-26按钮模式图标圆角大小
--wot-checkbox-button-font-size$typography-body-size-main按钮模式图标容器大小
--wot-checkbox-button-line-height$typography-body-line--height-size-main按钮模式字号
--wot-checkbox-button-bg$filled-bottom按钮模式行高
--wot-checkbox-button-bg-checked$filled-oppo按钮模式背景颜色
--wot-checkbox-icon-size$n-10按钮模式选中状态背景颜色
--wot-checkbox-button-min-widthcalc(74 * #{$n-1})按钮模式图标尺寸
--wot-checkbox-button-max-widthcalc(148 * #{$n-1})按钮模式最小宽
--wot-checkbox-button-border-radius$radius-main按钮模式最大宽
--wot-checkbox-button-padding$padding-extra-tight $padding-extra-loose按钮圆角大小
--wot-checkbox-button-icon-color$icon-white按钮模式内边距
--wot-checkbox-button-shape-topcalc(-1 * #{$n-11})按钮模式图标颜色
--wot-checkbox-button-shape-leftcalc(-1 * #{$n-9})按钮模式勾角顶部偏移
--wot-checkbox-button-shape-rightcalc(-1 * #{$n-9})按钮模式勾角左侧偏移
--wot-checkbox-button-icon-topcalc(13 * #{$n-1})按钮模式勾角右侧偏移
--wot-checkbox-button-icon-right$n-4按钮模式图标顶部偏移
--wot-checkbox-button-icon-left$n-4按钮模式图标右侧偏移

Source Code

Documentation
Component

Released under the MIT License.

Released under the MIT License.