{
  "component": "Checkbox",
  "package": "@blade-ai/weft",
  "status": "stable",
  "version": "0.1.0",
  "updated": "2026-11-24",
  "import": "import { Checkbox, CheckboxGroup } from \"@blade-ai/weft/components/checkbox\";",
  "docs": "/components/checkbox",
  "description": "Lets people pick any number of options from a list, or confirm a single choice such as accepting terms. Three values (unchecked, checked, indeterminate), three sizes, help and error text, plus CheckboxGroup for related options.",
  "props": [
    {
      "name": "Checkbox.label",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Visible text next to the box. Rendered inside the <label>; clicking it toggles the box. One of label or accessibilityLabel is required."
    },
    {
      "name": "Checkbox.accessibilityLabel",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Accessible name when there is no visible label (table rows). Becomes aria-label."
    },
    {
      "name": "Checkbox.isChecked",
      "type": "boolean",
      "default": null,
      "required": false,
      "description": "Controlled checked value. Use with onChange; the component never changes its own state when set."
    },
    {
      "name": "Checkbox.isDefaultChecked",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Initial value when uncontrolled. Ignored if isChecked is set."
    },
    {
      "name": "Checkbox.isIndeterminate",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Shows the dash and exposes the mixed state. Overrides the checked look; the app clears it when the children change."
    },
    {
      "name": "Checkbox.onChange",
      "type": "({ isChecked: boolean; value?: string; event }) => void",
      "default": null,
      "required": false,
      "description": "Fires on every toggle (click, label click, Space). Not fired when disabled or read-only. Required when controlled."
    },
    {
      "name": "Checkbox.name",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Form field name. Inside CheckboxGroup it comes from the group."
    },
    {
      "name": "Checkbox.value",
      "type": "string",
      "default": "on",
      "required": false,
      "description": "Value sent with the form when checked. Required inside CheckboxGroup."
    },
    {
      "name": "Checkbox.size",
      "type": "\"small\" | \"medium\" | \"large\"",
      "default": "medium",
      "required": false,
      "description": "Box 14 / 16 / 20px with label 12 / 14 / 16. Inside CheckboxGroup it comes from the group."
    },
    {
      "name": "Checkbox.helpText",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Hint under the label, linked with aria-describedby."
    },
    {
      "name": "Checkbox.errorText",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Shown when validationState is \"error\"; replaces helpText in the same slot. Required when validationState=\"error\"."
    },
    {
      "name": "Checkbox.validationState",
      "type": "\"none\" | \"error\"",
      "default": "none",
      "required": false,
      "description": "\"error\" draws the negative border and sets aria-invalid."
    },
    {
      "name": "Checkbox.isDisabled",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Native disabled: not focusable, not submitted, 50% opacity."
    },
    {
      "name": "Checkbox.isReadOnly",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Focusable and submitted, but the value cannot change. Sets aria-readonly. Visual treatment is UNDEFINED (gray fill proposed)."
    },
    {
      "name": "Checkbox.isRequired",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Must be checked to submit. Sets required. Visible required marker: UNDEFINED."
    },
    {
      "name": "Checkbox.autoFocus",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Focuses the checkbox input itself on mount (not the label or group)."
    },
    {
      "name": "Checkbox.testID",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Test selector on the input (data-testid)."
    },
    {
      "name": "CheckboxGroup.label",
      "type": "string",
      "default": null,
      "required": true,
      "description": "Legend text that names the group. Rendered as <legend>."
    },
    {
      "name": "CheckboxGroup.value",
      "type": "string[]",
      "default": null,
      "required": false,
      "description": "Checked values, controlled. Required with onChange when controlled."
    },
    {
      "name": "CheckboxGroup.defaultValue",
      "type": "string[]",
      "default": "[]",
      "required": false,
      "description": "Initial checked values when uncontrolled."
    },
    {
      "name": "CheckboxGroup.onChange",
      "type": "({ values: string[]; name?: string; event }) => void",
      "default": null,
      "required": false,
      "description": "Fires with the new list after any child toggles."
    },
    {
      "name": "CheckboxGroup.orientation",
      "type": "\"vertical\" | \"horizontal\"",
      "default": "vertical",
      "required": false,
      "description": "Stack (gap spacing-4) or row for 2-3 short options (gap spacing-7)."
    },
    {
      "name": "CheckboxGroup.name",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Form field name passed to every child. Required for forms."
    },
    {
      "name": "CheckboxGroup.size",
      "type": "\"small\" | \"medium\" | \"large\"",
      "default": "medium",
      "required": false,
      "description": "Passed to every child Checkbox."
    },
    {
      "name": "CheckboxGroup.helpText",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Hint under the group, linked to the fieldset with aria-describedby."
    },
    {
      "name": "CheckboxGroup.errorText",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Shown once under the group when validationState is \"error\"; replaces helpText."
    },
    {
      "name": "CheckboxGroup.validationState",
      "type": "\"none\" | \"error\"",
      "default": "none",
      "required": false,
      "description": "\"error\" gives every child the error border and aria-invalid."
    },
    {
      "name": "CheckboxGroup.isDisabled",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Disables every child."
    },
    {
      "name": "CheckboxGroup.isRequired",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "At least one must be checked; the app validates. Visible marker: UNDEFINED."
    }
  ],
  "undefined": [
    "Pressed fill for a checked box (--undefined-interactive-background-primary-pressed; falls back to the highlighted fill)",
    "Read-only visual treatment (gray fill proposed, not approved)",
    "When the error first shows: on submit (fallback) or on change",
    "Visible required marker (fallback: none; say it in the label)",
    "Check / dash motion (fallback: instant)"
  ],
  "sizes": {
    "boxWidthHeight": "small --size-14 · medium --size-16 · large --size-20",
    "boxBorderRadius": "1px (--border-width-thin) · --border-radius-none",
    "iconViewBox": "viewBox 0 0 16 16, fills the box · stroke-width 2 (small, medium) · 1.75 (large)",
    "boxToLabelGap": "small --spacing-15 · medium and large --spacing-3",
    "labelFontSize": "small --typography-fonts-size-75 · medium --typography-fonts-size-100 · large --typography-fonts-size-200",
    "labelLineHeight": "small --typography-line-heights-50 · medium --typography-line-heights-100 · large --typography-line-heights-1200",
    "helpErrorFontSize": "small and medium --typography-fonts-size-75 · large --typography-fonts-size-100",
    "helpErrorLineHeight": "small and medium --typography-line-heights-50 · large --typography-line-heights-100",
    "labelToHelpGap": "--spacing-2",
    "slotHeight": "= label line-height; the box is centred in it so it stays aligned when the label wraps",
    "groupLegend": "--typography-fonts-size-1200, line-height --typography-line-heights-100",
    "legendToOptionsGap": "--spacing-3",
    "optionsGap": "vertical --spacing-4 · horizontal --spacing-7",
    "mobileRowHeight": "large --size-48 (option row)",
    "paths": "check \"M3.8 8.2l2.9 2.9 5.5-6\" · dash \"M4 8h8\" · fill none · stroke = icon token"
  },
  "states": [
    {
      "name": "default · unchecked",
      "trigger": "resting",
      "tokens": {
        "bg": "surface.background.gray.subtle",
        "border": "interactive.border.gray.default",
        "icon": "none"
      }
    },
    {
      "name": "default · checked",
      "trigger": "resting",
      "tokens": {
        "bg": "interactive.background.primary.default",
        "border": "interactive.border.primary.default",
        "icon": "interactive.icon.onPrimary.normal"
      }
    },
    {
      "name": "hover · unchecked",
      "trigger": "pointer over the box or label",
      "tokens": {
        "bg": "surface.background.gray.subtle",
        "border": "interactive.border.gray.highlighted",
        "icon": "none"
      }
    },
    {
      "name": "hover · checked",
      "trigger": "pointer over the box or label",
      "tokens": {
        "bg": "interactive.background.primary.highlighted",
        "border": "interactive.border.primary.default",
        "icon": "interactive.icon.onPrimary.normal"
      }
    },
    {
      "name": "focus-visible · unchecked",
      "trigger": "keyboard focus",
      "tokens": {
        "bg": "surface.background.gray.subtle",
        "border": "interactive.border.primary.default + ring",
        "icon": "none"
      }
    },
    {
      "name": "focus-visible · checked",
      "trigger": "keyboard focus",
      "tokens": {
        "bg": "interactive.background.primary.default",
        "border": "interactive.border.primary.default + ring",
        "icon": "interactive.icon.onPrimary.normal"
      }
    },
    {
      "name": "pressed · unchecked",
      "trigger": "pointer or Space down",
      "tokens": {
        "bg": "interactive.background.gray.fadedHighlighted",
        "border": "interactive.border.gray.highlighted",
        "icon": "none"
      }
    },
    {
      "name": "pressed · checked",
      "trigger": "pointer or Space down",
      "tokens": {
        "bg": "UNDEFINED · needs decision (--undefined-interactive-background-primary-pressed)",
        "border": "interactive.border.primary.default",
        "icon": "interactive.icon.onPrimary.normal"
      }
    },
    {
      "name": "disabled · unchecked",
      "trigger": "isDisabled",
      "tokens": {
        "bg": "interactive.background.gray.disabled",
        "border": "interactive.border.gray.default",
        "icon": "none (+ opacity 50%)"
      }
    },
    {
      "name": "disabled · checked",
      "trigger": "isDisabled",
      "tokens": {
        "bg": "interactive.background.primary.default",
        "border": "interactive.border.primary.default",
        "icon": "interactive.icon.onPrimary.normal (+ opacity 50%)"
      }
    },
    {
      "name": "read-only · unchecked",
      "trigger": "isReadOnly",
      "tokens": {
        "bg": "surface.background.gray.subtle",
        "border": "interactive.border.gray.default",
        "icon": "none"
      }
    },
    {
      "name": "read-only · checked",
      "trigger": "isReadOnly (proposed, not approved)",
      "tokens": {
        "bg": "interactive.background.gray.default",
        "border": "interactive.border.gray.default",
        "icon": "interactive.icon.gray.normal"
      }
    },
    {
      "name": "invalid · unchecked",
      "trigger": "validationState=\"error\"",
      "tokens": {
        "bg": "surface.background.gray.subtle",
        "border": "feedback.border.negative.intense",
        "icon": "none"
      }
    },
    {
      "name": "invalid · checked",
      "trigger": "validationState=\"error\"",
      "tokens": {
        "bg": "interactive.background.primary.default",
        "border": "feedback.border.negative.intense",
        "icon": "interactive.icon.onPrimary.normal"
      }
    }
  ],
  "behaviour": {
    "toggle": "Click on the box or label, or Space, flips unchecked <-> checked and fires onChange. Enter never toggles.",
    "indeterminateClick": "Becomes checked; onChange({ isChecked: true }). The app clears isIndeterminate.",
    "controlled": "isChecked set: render it as-is; never change internal state.",
    "uncontrolled": "isDefaultChecked sets the first value; the component owns state afterwards.",
    "selectAllParent": "Checked if all children are checked; indeterminate if some; unchecked if none. Click: some or none -> all, all -> none.",
    "validationShow": "The app sets validationState=\"error\" + errorText. First trigger (on submit vs on change): UNDEFINED · needs decision. Fallback: on submit.",
    "validationClear": "Re-validate on every change; once valid, the error clears immediately (approved field rule).",
    "errorVsHelp": "errorText replaces helpText in the same slot; never both.",
    "groupError": "One message under the group; every child gets the error border and aria-invalid=\"true\".",
    "disabled": "Native disabled: no focus, no hover, no change, not sent with the form; opacity 50%.",
    "readOnly": "Focusable, sent with the form, change blocked. Visual treatment: UNDEFINED · needs decision (fallback: gray fill).",
    "requiredMarker": "Visible \"required\" marker: UNDEFINED · needs decision. Fallback: none; say it in the label.",
    "autoFocus": "Focus lands on the checkbox input itself (not the label, not the group).",
    "focusRing": "Only on :focus-visible (keyboard). Mouse and touch never show the ring.",
    "hover": "Box + label row is the hover target. No hover on touch devices.",
    "pressed": "Shown while pointer or Space is down; value changes on release.",
    "labelWrap": "Long labels wrap; the box stays centred on the first line.",
    "checkAnimation": "Check / dash motion: UNDEFINED · needs decision. Fallback: instant, no animation."
  },
  "keyboard": [
    {
      "key": "Tab / Shift+Tab",
      "action": "Next / previous checkbox; each is a tab stop; disabled skipped, read-only kept."
    },
    {
      "key": "Space",
      "action": "Toggle (unchecked <-> checked; indeterminate -> checked). No-op when read-only or disabled."
    },
    {
      "key": "Enter",
      "action": "No toggle; submits the form (native)."
    },
    {
      "key": "Arrow keys",
      "action": "No effect."
    },
    {
      "key": "Click label",
      "action": "Toggle + focus the input; no ring (not :focus-visible)."
    }
  ],
  "accessibility": {
    "summary": "Native <input type=\"checkbox\"> inside a real <label>; no key handlers. Group: <fieldset><legend>.",
    "aria": [
      {
        "element": "input",
        "attributes": "type=\"checkbox\"",
        "when": "Always"
      },
      {
        "element": "input",
        "attributes": "checked",
        "when": "isChecked"
      },
      {
        "element": "input",
        "attributes": "indeterminate (DOM property)",
        "when": "isIndeterminate; exposed as aria-checked=\"mixed\""
      },
      {
        "element": "input",
        "attributes": "aria-label",
        "when": "accessibilityLabel, only when there is no label"
      },
      {
        "element": "input",
        "attributes": "aria-describedby",
        "when": "id of helpText, or of errorText when invalid"
      },
      {
        "element": "input",
        "attributes": "aria-invalid=\"true\"",
        "when": "validationState = \"error\""
      },
      {
        "element": "input",
        "attributes": "aria-readonly=\"true\"",
        "when": "isReadOnly"
      },
      {
        "element": "input",
        "attributes": "required",
        "when": "isRequired"
      },
      {
        "element": "input",
        "attributes": "disabled",
        "when": "isDisabled"
      },
      {
        "element": "fieldset",
        "attributes": "aria-describedby",
        "when": "id of group helpText / errorText"
      },
      {
        "element": "legend",
        "attributes": "text",
        "when": "CheckboxGroup label"
      },
      {
        "element": "select-all input",
        "attributes": "aria-controls",
        "when": "space-separated ids of the child inputs (set by the app)"
      }
    ]
  },
  "usage": {
    "do": [
      "Use a native <input type=\"checkbox\"> and a real <label>; keep the input in the accessibility tree.",
      "Keep the 1px interactive/border/primary/default outline on checked and indeterminate boxes.",
      "Use only the Theme tokens listed under States; Global tokens only for size, spacing, radius, type.",
      "Wrap related options in CheckboxGroup (fieldset + legend) and show one group error.",
      "Write positive, sentence-case labels without end punctuation, e.g. \"Email me Blade AI product updates\".",
      "Clear the error as soon as the value becomes valid."
    ],
    "dont": [
      "Don't add component tokens (no checkbox/*); add a Theme token or flag UNDEFINED.",
      "Don't round the box: Weft uses --border-radius-none.",
      "Don't show the focus ring on mouse click; use :focus-visible.",
      "Don't toggle on Enter, and don't add arrow-key navigation.",
      "Don't use indeterminate on a lone checkbox, or a checkbox for an instant setting (use Switch).",
      "Don't hide the input with display:none or visibility:hidden."
    ]
  },
  "example": "<Checkbox label=\"Email me Blade AI product updates\" helpText=\"You can unsubscribe at any time.\" />"
}
