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 checkbox and checkbox groups fully supported
  • ✅ All visual states (checked, disabled, border, etc.) are consistent in SSR
  • ✅ Indeterminate state styling supported

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

Checkbox Props

PropDescriptionTypeDefault
model-value / v-modelBinding valuestring | number | boolean
valueValue when checked (used in checkbox-group)string | number | boolean
labelDisplay text (if no default slot)string
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'
nameNative name attributestring
checkedWhether currently checkedboolean
idInput idstring
tabindexInput tabindexstring | number

Checkbox Events

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

Checkbox Slots

Slot NameDescription
defaultCustom default content

Checkbox Expose

NameDescriptionType
refNative input elementRef<HTMLInputElement>
checkedWhether checkedboolean
focusFocus the input() => void
blurBlur the input() => void

CheckboxGroup Props

PropDescriptionTypeDefault
model-value / v-modelBinding valueArray<string | number | boolean>[]
sizeCheckbox group size'large' | 'default' | 'small'
disabledWhether disabledbooleanfalse
minMinimum number of checkable itemsnumber
maxMaximum number of checkable itemsnumber
text-colorActive text colorstring
fillActive fill and border colorstring
tagCustom element tagstring | Component'div'

CheckboxGroup Events

Event NameDescriptionParameters
changeTriggered when binding value changes(value: Array<string | number | boolean>) => void

CheckboxGroup Slots

Slot NameDescription
defaultCustom default content

Theme Variables

The Checkbox component uses the following CSS variables for style customization:

VariableDescriptionDefault
--yh-checkbox-font-sizeFont sizevar(--yh-font-size-base)
--yh-checkbox-text-colorText colorvar(--yh-text-color-regular)
--yh-checkbox-input-sizeCheckbox size14px
--yh-checkbox-input-border-colorBorder colorvar(--yh-border-color)
--yh-checkbox-input-bg-colorBackground colorvar(--yh-fill-color-blank)
--yh-checkbox-checked-bg-colorChecked backgroundvar(--yh-color-primary)
--yh-checkbox-checked-border-colorChecked bordervar(--yh-color-primary)
--yh-checkbox-checked-icon-colorChecked icon colorvar(--yh-fill-color-blank)
--yh-checkbox-disabled-bg-colorDisabled backgroundvar(--yh-fill-color-light)
--yh-checkbox-disabled-text-colorDisabled text colorvar(--yh-text-color-placeholder)

Released under the MIT License.