Checkbox
Overview
A control that lets the user select or clear an option, with an indeterminate half-check state for partial selections. It ships as a standalone control, a roving-focus group, and data-driven card variants. Use it for independent toggles, multi-select lists, and “select all” scenarios with cascading half-check; for single-choice from a set, prefer SRadioGroup.
Usage
Features
- ☑️ Tri-state model —
CheckedStateofboolean | 'indeterminate', reflected via botharia-checked(mixed) anddata-state - 🗂 Groups with roving-focus keyboard navigation (
useRovingFocusGroup, Arrow keys) - 🏷 Accessible label —
SCheckboxLabelwiresforto the control’sid - 📋 Native form proxy — renders a visually hidden input carrying
name/value(default'on') /checkedfor form submission - 🃏 Card variants (
SCheckboxCard/SCheckboxCardGroup) with icon, label, and description content - 🎨 6 sizes, 8 colors, 2 shapes, and horizontal/vertical orientation via
checkboxVariants - 📊 Data-driven Compact aggregation —
CheckboxGroupCompact/CheckboxCardGroupCompactown iteration and default composition - ♿
role="checkbox"with full aria support, axe-clean across all four forms
Component family
SCheckbox- base checkbox with label, control, and indicatorSCheckboxGroup- vertical/horizontal group with roving-focus navigation and form proxySCheckboxCard- card checkbox with icon, label, and descriptionSCheckboxCardGroup- data-driven group of card checkboxes
Demos
Basic
Icon
Group
Card
this is a description
Card Group
API
Aria Layer
13Checkbox
Props
| Prop | Type | Default | Description |
|---|---|---|---|
class | ClassValue | — | the class of root element |
ui | Partial<CheckboxUi> | — | Per-slot class overrides for the component. |
color | ThemeColor | — | Theme color of the component. |
size | ThemeSize | — | Visual size of the component. |
shape | CheckboxShape | — | Shape of the component. |
label | string | — | Label text rendered by the component. |
controlProps | CheckboxControlProps | — | Properties forwarded to the control element. |
indicatorProps | CheckboxIndicatorProps | — | Properties forwarded to the indicator element. |
labelProps | LabelProps | — | Properties forwarded to the label element. |
id | string | — | Id. |
modelValue | CheckedState | null | — | The controlled value of the checkbox. Can be bound with v-model. |
defaultValue | CheckedState | — | The value of the checkbox when it is initially rendered. Use when you do not need to control its value. |
value | DefinedValue | on | The value given as data when submitted with a `name`. |
disabled | boolean | false | When `true`, prevents the user from interacting with the checkbox |
name | string | — | The name of the field. Submitted with its owning form as part of a name/value pair. |
required | boolean | — | When `true`, indicates that the user must set the value before the owning form can be submitted. |
Emits
| Emit Name | Parameters | Description |
|---|---|---|
update:modelValue | CheckedState | null | Event handler called when the value of the checkbox changes. |
CheckboxCard
Props
| Prop | Type | Default | Description |
|---|---|---|---|
class | ClassValue | — | the class of root element |
ui | Partial<CheckboxCardUi> | — | Per-slot class overrides for the component. |
color | ThemeColor | — | Theme color of the component. |
size | ThemeSize | — | Visual size of the component. |
shape | CheckboxShape | — | Shape of the component. |
icon | string | — | Icon rendered by the component. |
description | string | — | Description text rendered by the component. |
label | string | — | Label text rendered by the component. |
controlProps | CheckboxControlProps | — | Properties forwarded to the control element. |
indicatorProps | CheckboxIndicatorProps | — | Properties forwarded to the indicator element. |
labelProps | LabelProps | — | Properties forwarded to the label element. |
id | string | — | Id. |
modelValue | CheckedState | null | — | The controlled value of the checkbox. Can be bound with v-model. |
defaultValue | CheckedState | — | The value of the checkbox when it is initially rendered. Use when you do not need to control its value. |
value | DefinedValue | on | The value given as data when submitted with a `name`. |
disabled | boolean | false | When `true`, prevents the user from interacting with the checkbox |
name | string | — | The name of the field. Submitted with its owning form as part of a name/value pair. |
required | boolean | — | When `true`, indicates that the user must set the value before the owning form can be submitted. |
Emits
| Emit Name | Parameters | Description |
|---|---|---|
update:modelValue | CheckedState | null | Event handler called when the value of the checkbox changes. |
CheckboxCardCompact
Props
| Prop | Type | Default | Description |
|---|---|---|---|
icon | IconValue | — | Icon rendered by the component. |
description | string | — | Description text rendered by the component. |
label | string | — | Label text rendered by the component. |
controlProps | CheckboxControlProps | — | Properties forwarded to the control element. |
indicatorProps | CheckboxIndicatorProps | — | Properties forwarded to the indicator element. |
labelProps | LabelProps | — | Properties forwarded to the label element. |
id | string | — | Id. |
modelValue | CheckedState | null | — | The controlled value of the checkbox. Can be bound with v-model. |
defaultValue | CheckedState | — | The value of the checkbox when it is initially rendered. Use when you do not need to control its value. |
value | DefinedValue | on | The value given as data when submitted with a `name`. |
disabled | boolean | false | When `true`, prevents the user from interacting with the checkbox |
name | string | — | The name of the field. Submitted with its owning form as part of a name/value pair. |
required | boolean | — | When `true`, indicates that the user must set the value before the owning form can be submitted. |
Emits
| Emit Name | Parameters | Description |
|---|---|---|
update:modelValue | CheckedState | null | Event handler called when the value of the checkbox changes. |
CheckboxCardGroup<T>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
class | ClassValue | — | the class of group root element |
ui | Partial<CheckboxCardUi> | — | Per-slot class overrides for the component. |
color | ThemeColor | — | Theme color of the component. |
size | ThemeSize | — | Visual size of the component. |
shape | CheckboxShape | — | Shape of the component. |
items | T[] | — | Items rendered by the component. |
rootProps | CheckboxRootProps | — | Properties forwarded to the root element. |
controlProps | CheckboxControlProps | — | Properties forwarded to the control element. |
indicatorProps | CheckboxIndicatorProps | — | Properties forwarded to the indicator element. |
labelProps | LabelProps | — | Properties forwarded to the label element. |
modelValue | T['value'][] | — | The controlled value of the checkbox. Can be bound with v-model. |
defaultValue | T['value'][] | — | The value of the checkbox when it is initially rendered. Use when you do not need to control its value. |
rovingFocus | boolean | true | When `false`, navigating through the items using arrow keys will be disabled. |
disabled | boolean | false | When `true`, prevents the user from interacting with the checkboxes |
dir | Direction | — | The direction of navigation between items. |
loop | boolean | false | Whether keyboard navigation should loop around |
orientation | DataOrientation | — | The orientation of the group. Mainly so arrow navigation is done accordingly (left & right vs. up & down) |
name | string | — | The name of the field. Submitted with its owning form as part of a name/value pair. |
required | boolean | — | When `true`, indicates that the user must set the value before the owning form can be submitted. |
Emits
| Emit Name | Parameters | Description |
|---|---|---|
update:modelValue | T[] | Event handler called when the value of the checkbox group changes. |
CheckboxCardGroupCompact<T>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
items | T[] | — | Items rendered by the component. |
rootProps | CheckboxRootProps | — | Properties forwarded to the root element. |
controlProps | CheckboxControlProps | — | Properties forwarded to the control element. |
indicatorProps | CheckboxIndicatorProps | — | Properties forwarded to the indicator element. |
labelProps | LabelProps | — | Properties forwarded to the label element. |
modelValue | T['value'][] | — | The controlled value of the checkbox. Can be bound with v-model. |
defaultValue | T['value'][] | — | The value of the checkbox when it is initially rendered. Use when you do not need to control its value. |
rovingFocus | boolean | true | When `false`, navigating through the items using arrow keys will be disabled. |
disabled | boolean | false | When `true`, prevents the user from interacting with the checkboxes |
dir | Direction | — | The direction of navigation between items. |
loop | boolean | false | Whether keyboard navigation should loop around |
orientation | DataOrientation | — | The orientation of the group. Mainly so arrow navigation is done accordingly (left & right vs. up & down) |
name | string | — | The name of the field. Submitted with its owning form as part of a name/value pair. |
required | boolean | — | When `true`, indicates that the user must set the value before the owning form can be submitted. |
Emits
| Emit Name | Parameters | Description |
|---|---|---|
update:modelValue | T[] | Event handler called when the value of the checkbox group changes. |
CheckboxCompact
Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | — | Label text rendered by the component. |
controlProps | CheckboxControlProps | — | Properties forwarded to the control element. |
indicatorProps | CheckboxIndicatorProps | — | Properties forwarded to the indicator element. |
labelProps | LabelProps | — | Properties forwarded to the label element. |
id | string | — | Id. |
modelValue | CheckedState | null | — | The controlled value of the checkbox. Can be bound with v-model. |
defaultValue | CheckedState | — | The value of the checkbox when it is initially rendered. Use when you do not need to control its value. |
value | DefinedValue | on | The value given as data when submitted with a `name`. |
disabled | boolean | false | When `true`, prevents the user from interacting with the checkbox |
name | string | — | The name of the field. Submitted with its owning form as part of a name/value pair. |
required | boolean | — | When `true`, indicates that the user must set the value before the owning form can be submitted. |
Emits
| Emit Name | Parameters | Description |
|---|---|---|
update:modelValue | CheckedState | null | Event handler called when the value of the checkbox changes. |
CheckboxControl
Props
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | — | Id of the element |
type | ButtonType | 'button' | The type of the button element. Can be one of 'button', 'submit', or 'reset'. |
disabled | boolean | — | Whether the component is disabled. |
asChild | boolean | — | Change the default rendered element for the one passed as a child, merging their props and behavior. |
as | AsTag | Component | 'div' | The element or component this component should render as. Can be overwrite by `asChild` |
CheckboxGroup<T>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
class | ClassValue | — | the class of group root element |
ui | Partial<CheckboxUi> | — | Per-slot class overrides for the component. |
color | ThemeColor | — | Theme color of the component. |
size | ThemeSize | — | Visual size of the component. |
shape | CheckboxShape | — | Shape of the component. |
items | T[] | — | Items rendered by the component. |
rootProps | CheckboxRootProps | — | Properties forwarded to the root element. |
controlProps | CheckboxControlProps | — | Properties forwarded to the control element. |
indicatorProps | CheckboxIndicatorProps | — | Properties forwarded to the indicator element. |
labelProps | LabelProps | — | Properties forwarded to the label element. |
modelValue | T['value'][] | — | The controlled value of the checkbox. Can be bound with v-model. |
defaultValue | T['value'][] | — | The value of the checkbox when it is initially rendered. Use when you do not need to control its value. |
rovingFocus | boolean | true | When `false`, navigating through the items using arrow keys will be disabled. |
disabled | boolean | false | When `true`, prevents the user from interacting with the checkboxes |
dir | Direction | — | The direction of navigation between items. |
loop | boolean | false | Whether keyboard navigation should loop around |
orientation | DataOrientation | — | The orientation of the group. Mainly so arrow navigation is done accordingly (left & right vs. up & down) |
name | string | — | The name of the field. Submitted with its owning form as part of a name/value pair. |
required | boolean | — | When `true`, indicates that the user must set the value before the owning form can be submitted. |
Emits
| Emit Name | Parameters | Description |
|---|---|---|
update:modelValue | T[] | Event handler called when the value of the checkbox group changes. |
CheckboxGroupCompact<T>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
items | T[] | — | Items rendered by the component. |
rootProps | CheckboxRootProps | — | Properties forwarded to the root element. |
controlProps | CheckboxControlProps | — | Properties forwarded to the control element. |
indicatorProps | CheckboxIndicatorProps | — | Properties forwarded to the indicator element. |
labelProps | LabelProps | — | Properties forwarded to the label element. |
modelValue | T['value'][] | — | The controlled value of the checkbox. Can be bound with v-model. |
defaultValue | T['value'][] | — | The value of the checkbox when it is initially rendered. Use when you do not need to control its value. |
rovingFocus | boolean | true | When `false`, navigating through the items using arrow keys will be disabled. |
disabled | boolean | false | When `true`, prevents the user from interacting with the checkboxes |
dir | Direction | — | The direction of navigation between items. |
loop | boolean | false | Whether keyboard navigation should loop around |
orientation | DataOrientation | — | The orientation of the group. Mainly so arrow navigation is done accordingly (left & right vs. up & down) |
name | string | — | The name of the field. Submitted with its owning form as part of a name/value pair. |
required | boolean | — | When `true`, indicates that the user must set the value before the owning form can be submitted. |
Emits
| Emit Name | Parameters | Description |
|---|---|---|
update:modelValue | T[] | Event handler called when the value of the checkbox group changes. |
CheckboxGroupRoot<T>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
modelValue | T[] | — | The controlled value of the checkbox. Can be bound with v-model. |
defaultValue | T[] | — | The value of the checkbox when it is initially rendered. Use when you do not need to control its value. |
rovingFocus | boolean | true | When `false`, navigating through the items using arrow keys will be disabled. |
disabled | boolean | false | When `true`, prevents the user from interacting with the checkboxes |
dir | Direction | — | The direction of navigation between items. |
loop | boolean | false | Whether keyboard navigation should loop around |
orientation | DataOrientation | — | The orientation of the group. Mainly so arrow navigation is done accordingly (left & right vs. up & down) |
name | string | — | The name of the field. Submitted with its owning form as part of a name/value pair. |
required | boolean | — | When `true`, indicates that the user must set the value before the owning form can be submitted. |
Emits
| Emit Name | Parameters | Description |
|---|---|---|
update:modelValue | T[] | Event handler called when the value of the checkbox group changes. |
CheckboxIndicator
Props
| Prop | Type | Default | Description |
|---|---|---|---|
forceMount | boolean | — | Used to force mounting when more control is needed.
Useful when controlling animation with Vue animation libraries. |
asChild | boolean | — | Change the default rendered element for the one passed as a child, merging their props and behavior. |
as | AsTag | Component | 'div' | The element or component this component should render as. Can be overwrite by `asChild` |
CheckboxLabel
CheckboxRoot
Props
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | — | Id. |
modelValue | CheckedState | null | — | The controlled value of the checkbox. Can be bound with v-model. |
defaultValue | CheckedState | — | The value of the checkbox when it is initially rendered. Use when you do not need to control its value. |
value | DefinedValue | on | The value given as data when submitted with a `name`. |
disabled | boolean | false | When `true`, prevents the user from interacting with the checkbox |
name | string | — | The name of the field. Submitted with its owning form as part of a name/value pair. |
required | boolean | — | When `true`, indicates that the user must set the value before the owning form can be submitted. |
Emits
| Emit Name | Parameters | Description |
|---|---|---|
update:modelValue | CheckedState | null | Event handler called when the value of the checkbox changes. |
Notes
Architecture and benchmark differences
VeanUI builds checkbox with a single-source tri-state state machine: CheckboxRoot (useControllableState + CheckedState) derives ariaChecked (indeterminate → mixed) and dataState (checked / indeterminate / unchecked), which CheckboxControl reflects on role="checkbox" while CheckboxIndicator mounts conditionally via usePresence. Group value changes are emitted by CheckboxGroupRoot, which wraps useRovingFocusGroup for arrow-key navigation and renders a VisuallyHiddenInput form proxy. The scv() recipes checkboxVariants / checkboxCardVariants declare 6 sizes, 8 colors, and 2 shapes; all four Compact layers own iteration and default composition while the UI wrappers only inject variant classes.
| Capability | VeanUI | Ant Design Checkbox | Element Plus Checkbox | Mantine Checkbox | shadcn/ui Checkbox |
|---|---|---|---|---|---|
| Aria/styled split | ✅ | — | — | — | ✅ |
| Tri-state (indeterminate) | ✅ | ✅ | ✅ | ✅ | ✅ |
Independent indeterminate prop | ➕ | ✅ | ✅ | ✅ | — |
| Form value mapping | ✅ | ✅ | ✅ | ✅ | ✅ |
| Card variant (icon/description) | ✅ | — | — | — | — |
| Group roving-focus keyboard nav | ✅ | ✅ | ✅ | ✅ | — |
button variant | ➕ | ✅ | ✅ | — | — |
| Select-all / half-check helper | ➕ | ✅ | — | — | — |
Cautions
- The half-check state is driven by
modelValue="indeterminate"; a dedicatedindeterminateprop is a roadmap enhancement, not yet implemented. - A
disabledgroup disables every item; an individualdisabledon an item is honored inside an enabled group. - The form proxy activates when a
nameis present — pair it with a native<form>or theSFormintegration to submit values. - The indicator uses
pointer-events: noneso clicks always land on the control itself.
FAQ
How do I show a partial / indeterminate state?
Pass modelValue="indeterminate" (or defaultValue); the control reflects aria-checked="mixed" and data-state="indeterminate".
How do I build a “select all” list?
Combine a master SCheckbox with modelValue="indeterminate" and an SCheckboxGroup; mirror the group’s update:modelValue back to the master to drive the half-check.
How do I submit checkbox values with a form?
Give the checkbox or group a name; the component renders a visually hidden input so native form submission carries value (default 'on') or the array of checked values.
What is the difference between SCheckboxCard and SCheckbox?
SCheckboxCard renders a bordered card with icon / label / description content slots and a data-[state=checked] border highlight; SCheckbox is the bare control.