Skip to content

Checkbox ​

Checkbox component.

When To Use ​

  • Used for selecting multiple values from several options.
  • If you use only one checkbox, it is the same as using toggle to toggle between two states. The difference is that toggle will trigger the state change directly, but Checkbox just marks the state as changed and this needs to be submitted.

Demo ​

Basic Usage ​

Intermediate ​

Sizes ​

Here are several predefined checkbox sizes, each serving its own semantic purpose.

Readonly ​

Make input look inactive by adding the disabled boolean attribute to any <input> element.

Disabled ​

Make input look inactive by adding the disabled boolean attribute to any <input> element.

API ​

Properties ​

PropertyAttributeDescriptionTypeDefault
configAriaconfig-ariaThe ARIA attribute configuration object is used to dynamically set ARIA attributes (such as aria-label, aria-describedby, etc.). The component will automatically collect all aria-* attributes on the element into this object.any{}
disableddisabledDisabled state When set to true, the component is not interactable and visually grayed outbooleanfalse
intermediateintermediateIntermediate state When set to true, a "-" icon is displayed, indicating a partially selected state. It is mutually exclusive with the value attribute (value should be false in the intermediate state)booleanfalse
labellabelCheckbox label textstringundefined
layerlayerVisual hierarchy controls the depth of the component in the UI, affecting shadows and background colors:
01: surface component (highest level)
02: middle component
background: background component (lowest level)
"01" | "02" | "background"undefined
namenameForm field name (auto-generated)string`zane-input-${this.gid}`
readonlyreadonlyRead-only statusbooleanfalse
requiredrequiredRequired statusbooleanfalse
roundedroundedRounded Corner Stylebooleanfalse
sizesizeSize specifications
lg: large size (48px)
md: medium size (40px)
sm: small size (32px)
"lg" | "md" | "sm"'md'
valuevalueSelected state When set to true, the selected icon is displayed. It is mutually exclusive with the intermediate property.booleanfalse

Events ​

EventDescriptionType
zane-checkbox--blurLost focus eventCustomEvent<any>
zane-checkbox--change值变更事件Value Change EventsCustomEvent<any>
zane-checkbox--focusGet focus eventCustomEvent<any>

Methods ​

getComponentId() => Promise<string> ​

Get component ID

Returns ​

Type: Promise<string>

Component unique identifier

setBlur() => Promise<void> ​

Remove focus

Returns ​

Type: Promise<void>

setFocus() => Promise<void> ​

Setting the focus

Returns ​

Type: Promise<void>

Dependencies ​

Used by ​

Released under the MIT License.