Skip to content

Checkbox

Toggle one optional value or represent a partially selected parent.

Usage

Binary

Represent one optional value with ordinary checked and unchecked states.

Represent one optional value with ordinary checked and unchecked states.

Mixed

Represent a parent whose child values are only partly selected.

Represent a parent whose child values are only partly selected.

Controlled

Let the parent own the current value and apply accepted changes back to the component.

Let the parent own the current value and apply accepted changes back to the component.

API

Vue package: @sectile/vue/checkbox

Components
  • CheckboxRoot
  • CheckboxIndicator

Props

CheckboxRootProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

defaultValue

Initial value used when the component owns its state.

disabled

Whether interaction is unavailable.

form

ID of the native form associated with the control.

modelValue

Current value when state is controlled by the parent.

name

Name used for native form submission.

readonly

Whether the value can be inspected but not changed.

required

Whether the control must contain a valid value before submission.

value

Current value exposed by this contract.

CheckboxIndicatorProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

Slots

CheckboxSlotProps

checked

Whether the control is checked.

disabled

Whether interaction is unavailable.

isChecked

Whether this checkbox value is selected.

isIndeterminate

Whether only part of a grouped value is selected.

readonly

Whether the value can be inspected but not changed.

Events

CheckboxRoot

update:modelValue

Emitted when the component requests a new controlled value.

Other types

CheckboxValue

ts
type CheckboxValue = boolean | 'indeterminate'

CheckboxValueChangeHandler

ts
type CheckboxValueChangeHandler = (value: CheckboxValue) => void

Parts

Shared scope: [data-scope="checkbox"]. Combine it with a part selector to keep styles local to this component.

PartSelectorRoleExtra attributes
root[data-part="root"]Defines the component boundary and owns its composed parts.
indicator[data-part="indicator"]Shows state or position without replacing the primary content.

Keyboard interaction

KeyBehavior
SpaceToggle the current value.
TabMove through the normal document focus order.

Accessibility

The root exposes checkbox semantics, including the mixed value through aria-checked="mixed".

See the corresponding WAI-ARIA pattern for the host accessibility contract.

Released under the MIT License.