Skip to content

Checkbox

Select multiple options from a set of alternatives.

Basic Usage

Used alone, it can toggle between two states. Bind a Boolean variable with v-model.

Basic Usage

Disabled

Use the disabled prop to control the checkbox disabled state.

Disabled

Checkbox Group

Useful when binding multiple checkboxes to the same array.

Checked: [ "Option A" ]

Checkbox Group

Indeterminate

The indeterminate prop represents the checkbox's indeterminate state, commonly used to implement a "select all" effect.

Indeterminate (Select All)

With Border

Use the border prop to render checkboxes with borders.

With Border

Sizes

Use the size prop to set checkbox sizes.

Sizes

Limit Selection Count

Use min and max props to limit the number of items that can be checked.

Min 1, Max 2

Limit Selection Count

Custom Check Values

Use true-value and false-value props to customize the checked and unchecked values.

Bound value type: string, value: no

Custom Check Values

Use in Nuxt

The Checkbox component fully supports SSR rendering in Nuxt 3/4. Components are auto-imported in Nuxt projects.

Use in Nuxt

SSR Notes:

  • Single checkboxes and checkbox groups can be rendered during SSR.
  • Checked, disabled, border, and other visual states stay consistent after hydration.
  • The indeterminate state is style-only and can also be rendered safely on the server.

SSR Safety

The Checkbox component has passed comprehensive SSR testing, ensuring server-rendered results are consistent with client-side hydrated structures, avoiding Hydration warnings.

API

Props

Checkbox

PropDescriptionTypeDefault
model-value / v-modelBound value.YhCheckboxValueTypeundefined
valueValue used in checkbox-group mode.YhCheckboxValueTypeundefined
labelDisplay text when no default slot is provided.stringundefined
true-valueValue when checkedstring | number | booleantrue
false-valueValue when uncheckedstring | number | booleanfalse
disabledWhether disabledbooleanfalse
indeterminateSet indeterminate state (style only)booleanfalse
borderWhether to show borderbooleanfalse
sizeCheckbox size'large' | 'default' | 'small''default'
validate-eventWhether form validation is triggered on value change.booleantrue
nameNative name attributestringundefined
checkedControlled checked statebooleanundefined
idNative input idstringundefined
tabindexNative tabindex valuestring | numberundefined
theme-overridesComponent-level theme variable overridesComponentThemeVarsundefined

Checkbox Group

PropDescriptionTypeDefault
model-value / v-modelBinding valueArray<string | number | boolean>[]
optionsOptional group option listYhCheckboxGroupOption[]undefined
sizeCheckbox group size'large' | 'default' | 'small'undefined
disabledWhether disabledbooleanfalse
minMinimum number of checked itemsnumberundefined
maxMaximum number of checked itemsnumberundefined
validate-eventWhether to trigger form validation on changebooleantrue
text-colorActive text color for button-like usagestringundefined
fillActive fill and border color for button-like usagestringundefined
tagWrapper element tagstring | Component'div'
theme-overridesComponent-level theme variable overridesComponentThemeVarsundefined

Events

Checkbox

Event NameDescriptionParameters
changeTriggered when binding value changes(value: string | number | boolean) => void
update:modelValueTriggered when the bound value changes(value: string | number | boolean) => void

Checkbox Group

Event NameDescriptionParameters
changeTriggered when checked values change(value: Array<string | number | boolean>) => void
update:modelValueTriggered when the bound array changes(value: Array<string | number | boolean>) => void

Slots

Checkbox

Slot NameDescriptionParameters
defaultCustom checkbox content.-

Checkbox Group

Slot NameDescriptionParameters
defaultCustom group content.-

Expose

Checkbox

NameDescriptionType
refNative input element.HTMLInputElement | undefined
checkedWhether checkedboolean
focusFocus the input() => void
blurBlur the input() => void

YhCheckboxGroup does not expose public instance methods or properties.

Theme Variables

VariableDescriptionDefault
--yh-checkbox-font-sizeFont sizevar(--yh-font-size-base)
--yh-checkbox-font-weightFont weightvar(--yh-font-weight-medium)
--yh-checkbox-text-colorText colorvar(--yh-text-color-regular)
--yh-checkbox-input-heightCheckbox input height14px
--yh-checkbox-input-widthCheckbox input width14px
--yh-checkbox-border-radiusCheckbox corner radiusvar(--yh-radius-sm)
--yh-checkbox-bg-colorCheckbox input background colorvar(--yh-fill-color-blank)
--yh-checkbox-input-borderCheckbox input border1px solid var(--yh-border-color)
--yh-checkbox-input-border-color-hoverHover border colorvar(--yh-color-primary)
--yh-checkbox-checked-bg-colorChecked backgroundvar(--yh-color-primary)
--yh-checkbox-checked-icon-colorChecked icon colorvar(--yh-fill-color-blank)
--yh-checkbox-checked-text-colorChecked text colorvar(--yh-color-primary)
--yh-checkbox-disabled-input-fillDisabled input backgroundvar(--yh-fill-color-light)
--yh-checkbox-disabled-border-colorDisabled border colorvar(--yh-border-color)
--yh-checkbox-disabled-icon-colorDisabled icon colorvar(--yh-text-color-placeholder)
--yh-checkbox-disabled-checked-input-fillDisabled checked backgroundvar(--yh-border-color)
--yh-checkbox-disabled-checked-input-border-colorDisabled checked border colorvar(--yh-border-color)
--yh-checkbox-disabled-checked-icon-colorDisabled checked icon color#fff

Type Exports

NameDescription
YhCheckboxPropsProps type for YhCheckbox
YhCheckboxEmitsEmits type for YhCheckbox
YhCheckboxSlotsSlots type for YhCheckbox
YhCheckboxExposeExpose type for YhCheckbox
YhCheckboxGroupPropsProps type for YhCheckboxGroup
YhCheckboxGroupEmitsEmits type for YhCheckboxGroup
YhCheckboxGroupOptionGroup option type
YhCheckboxValueTypeCheckbox value type
YhCheckboxInstancePublic instance type for YhCheckbox
YhCheckboxGroupInstancePublic instance type for YhCheckboxGroup

Released under the MIT License.