Skip to content
🌏 Translated with the assistance of DeepSeek and ChatGPT

Checkbox

This is for multiple choices.

Basic Usage

For the Checkbox component, passing modelValue puts it in controlled mode. Not passing it or passing undefined puts it in uncontrolled mode, where you can pass the defaultValue property as the default value.

Checkbox has two style variants: normal mode ('normal', default) and retro mode (retro). The retro mode style is a tribute to early game UI.

Hide source code

Disabled and Read-only States

For the Checkbox component, use readonly to set it as read-only and disabled to set it as disabled. In both cases, the internal <input> will be set to disabled, and the difference between them is almost only in styling.

Hide source code

Checkbox Group

You can combine CheckboxGroup and Checkbox to form a checkbox group.

The value of CheckboxGroup is an array composed of the value of selected Checkbox components.

Similarly, CheckboxGroup enters controlled mode when modelValue is passed. Not passing it or passing undefined puts it in uncontrolled mode, where you can pass the defaultValue property as the default value.

Retro Style

Readonly

Disabled

Hide source code

Indeterminate State

Setting Checkbox's indeterminate to true can put the checkbox in an indeterminate state. This property only controls the styling and is independent of the current checkbox value.





Hide source code

Vertical Arrangement

The direction property of CheckboxGroup is used to set the arrangement direction of child checkboxes.



Hide source code

Checkbox Sizes

Both Checkbox and CheckboxGroup have a size property that can be used to set the size of checkbox.

Single Checkbox

Group

Hide source code

Options Property

The options property of CheckboxGroup is used to directly pass in options, enabling quick creation of simple checkbox groups.



Hide source code

API

CheckboxProps

AttributeTypeOptionalDefaultDescriptionVersion
modelValueboolean | nullTrueThe value of the Checkbox component (controlled mode).0.0.3
defaultValueboolean | nullTrueThe default value of the Checkbox component (uncontrolled mode).0.0.3
indeterminatebooleanTruefalseIndeterminate state.0.0.3
disabledbooleanTruefalseDisabled state.0.0.3
readonlybooleanTruefalseRead-only state.0.0.3
variant'normal' | 'retro'True'normal'The style variant of the checkbox.0.0.3
labelstringTrueThe text of the checkbox.0.0.3
valueanyTruethe native value attribute of checkboxes.0.0.3
size'medium' | 'large' | 'small'True'medium'Size of the checkbox.0.0.3
pollSizeChangebooleanTruefalseEnables polling for component size changes. This may impact performance.0.1.0

CheckboxEvents

EventParameterDescriptionVersion
update:modelValuevalue: booleanCallback for updating modelValue.0.0.3
inputvalue: boolean, event: InputEventCallback for selecting/deselecting the checkbox.0.0.3
changevalue: boolean, event: EventCallback for when the checkbox selection state changes.0.0.3
focusevent: FocusEventCallback for when the checkbox is focused.0.0.3
blurevent: FocusEventCallback for when the checkbox loses focus.0.0.3

CheckboxSlots

SlotParameterDescriptionVersion
defaultThe text of the checkbox.0.0.3

CheckboxGroupProps

AttributeTypeOptionalDefaultDescriptionVersion
modelValueany[] | nullTrueThe value of the CheckboxGroup component (controlled mode).0.0.3
defaultValueany[] | nullTrueThe default value of the CheckboxGroup component (uncontrolled mode).0.0.3
disabledbooleanTruefalseDisabled state.0.0.3
readonlybooleanTruefalseRead-only state.0.0.3
variant'normal' | 'retro'TrueThe style variant for descendant Radio components, which takes precedence over the variant of individual Radio components if set.0.0.3
direction'horizontal' | 'vertical'True'horizontal'The arrangement direction of child checkbox components.0.0.3
options(CheckboxGroupOption | string)[]TrueOptions for the checkbox group.0.0.3
size'medium' | 'large' | 'small'True'medium'Size for descendant checkbox components. When set, it overrides the size prop on those components.0.0.3
pollSizeChangebooleanTruefalseEnables polling for component size changes. This also affects the property of the same name in Checkbox sub-components.0.1.0

CheckboxGroupEvents

EventParameterDescriptionVersion
update:modelValuevalue: any[]Callback for updating modelValue.0.0.3
changevalue: any[]Callback for when the checkbox group selection changes.0.0.3

CheckboxGroupSlots

SlotParameterDescriptionVersion
defaultChild checkbox components.0.0.3

Option

ts
export interface Option<T = any> {
	value: T
	label: string
}

CheckboxGroupOption

ts
export interface CheckboxGroupOption<T = any> extends Option<T> {
	disabled?: boolean
	key?: string | number | symbol
}