Skip to content

OCheckbox ​

OCheckbox renders a native checkbox for a standalone boolean or a selected-value group.

Usage ​

Step by step ​

  1. Import OCheckbox from the ooko-ui/checkbox public subpath.
  2. Bind a standalone checkbox to a boolean with v-model.
  3. For a group, bind an array and give each checkbox a distinct value with the same name.

Example ​

The rendered example and its source come from the same Vue single-file component.

Interactive playground ​

Change the value, label, guidance, size, and checkbox states. The preview updates immediately.

We only send relevant news.

Props ​

PropTypeDefaultDescription
sizeOokoFormControlSizeundefinedControls the choice control's form-control scale.
labelstringundefinedVisible or visually hidden accessible label.
idstringundefinedNative input identifier. A hydration-safe identifier is generated when omitted.
namestringundefinedNative form field name and OForm validation key.
hintstringundefinedPersistent guidance displayed below the choice control.
errorstringundefinedControlled validation error displayed below the choice control.
validationOokoValidationBindingundefinedValidation binding created by useOokoValidation.
hideLabelbooleanfalseVisually hides the label while preserving its accessible name.
requiredbooleanfalseMarks the native input as required.
disabledbooleanfalseDisables the native input.
readonlybooleanfalsePrevents changes while keeping the input focusable.
modelValueboolean | readonly Value[]undefinedControlled boolean state for a standalone checkbox. Selected values for a checkbox group.
valueValueundefinedValue submitted by a standalone checked checkbox. Value represented by this checkbox in the group.

Events ​

EventPayloadDescription
update:modelValueboolean | Value[]Emits the next boolean state or next selected group values after a native change.

Slots ​

SlotPropsDescription
defaultnoneProvides the checkbox label content.
TypeDefinition
OCheckboxModelValuetype OCheckboxModelValue<Value extends OCheckboxValue = OCheckboxValue> = boolean | readonly Value[];
OCheckboxValuetype OCheckboxValue = number | string;
OokoFormControlSizetype OokoFormControlSize = "sm" | "md";

CSS custom properties ​

Custom propertyDefaultDescription
--o-checkbox-gapvar(--o-space-2)Sets the space between the checkbox indicator and its label.
--o-checkbox-indicator-sizevar(--o-space-5)Sets the checkbox indicator size.
--o-checkbox-indicator-border-radiusvar(--o-radius-control-compact)Sets the checkbox indicator corner radius.
--o-checkbox-focus-width0.1875remSets the focus outline width.
--o-checkbox-focus-stylesolidSets the focus outline style.
--o-checkbox-focus-offset0.125remSets the distance between the indicator and focus outline.
--o-checkbox-disabled-opacity0.5Sets the opacity of a disabled checkbox.

Override example ​

css
:root {
  --o-checkbox-gap: var(--o-space-3);
}

Accessibility ​

The native checkbox and its control row form one label, so clicking the indicator or text toggles it. Space toggles it, focus is visibly indicated, and disabled behavior uses the native attribute. readonly remains focusable and exposes aria-readonly; it does not change value. Hints and feedback are referenced by aria-describedby, while errors are announced politely. Forced-colors and reduced-motion preferences are respected.

Behavior and edge cases ​

With a boolean v-model, the component emits the next boolean state. With an array v-model, value is required and the component immutably adds or removes that value like a native checkbox group. Native attributes and listeners are forwarded to the input; consumer classes and styles apply to the component root. size accepts sm and md, and may be configured through app defaults. Setting the native indeterminate property on the input, for instance with a forwarded :indeterminate binding, displays a dash instead of the check mark.