Skip to content

Checkbox

Checkboxes let users select one or more options from a list. They support checked, unchecked, and indeterminate states.

$cookest-ui add checkbox

Variants

Unchecked, checked, and indeterminate — the three core visual states.

Unchecked
Unchecked
Indeterminate

Sizes

Three sizes — sm (14 px), md (16 px), lg (20 px) — to fit any context.

States

Disabled prevents interaction; error highlights invalid or required fields.

Checkbox Group

A select-all parent checkbox with indeterminate state driven by child selections.

With Label & Description

Checkboxes used in form agreements — each with a primary label and supporting description.

PropTypeDefaultDescription
checkedbooleanfalseWhether the checkbox is checked.
indeterminatebooleanfalseShows a minus (−) icon to indicate partial child selection.
size"sm" | "md" | "lg""md"Controls the visual size of the checkbox box and label text.
disabledbooleanfalsePrevents interaction and renders the checkbox at reduced opacity.
errorbooleanfalseHighlights the checkbox with an error ring (requires acceptance).
labelstringPrimary label text rendered beside the checkbox.
descriptionstringSecondary helper text shown below the label.
idstringHTML id forwarded to the label element for external association.
onChange(checked: boolean) => voidCallback fired with the new boolean state on every click.

Related Components

Best Practices

✅ Do

  • Use for multi-select options in forms
  • Use indeterminate to signal partial group selection
  • Always pair with a visible, descriptive label
  • Show an error state when a required checkbox is unchecked

❌ Don't

  • Use checkboxes as toggle switches for instant settings
  • Leave checkboxes without a label or aria-label
  • Nest checkbox groups more than one level deep
  • Use a single standalone checkbox for binary yes/no — use Toggle instead

Accessibility

FeatureSupport
Keyboard: Space to toggleSpace key checks or unchecks the focused checkbox
aria-checkedReflects checked, unchecked, or mixed (indeterminate) state
aria-disabledCommunicated to assistive technologies when disabled
Label associationhtmlFor/id pair connects label text to the control
Focus visible ringVisible outline on keyboard navigation for all interactive states
role="checkbox"Implicit on native input type=checkbox; use explicit role for custom implementations