{
  "component": "Radio",
  "package": "@blade-ai/weft",
  "status": "stable",
  "version": "0.1.0",
  "updated": "2026-11-24",
  "import": "import { Radio, RadioGroup } from \"@blade-ai/weft/components/radio\";",
  "docs": "/components/radio",
  "description": "Lets people choose exactly one option from a short list. RadioGroup owns the name, value and validation; each Radio is one option with a label and optional help text.",
  "props": [
    {
      "name": "Radio.value",
      "type": "string",
      "default": null,
      "required": true,
      "description": "Value submitted when this option is selected. Unique within the group."
    },
    {
      "name": "Radio.children",
      "type": "ReactNode",
      "default": null,
      "required": false,
      "description": "Visible label, rendered inside the <label>; clicking it selects the option. Required unless the input is given an aria-label (prop name UNDEFINED)."
    },
    {
      "name": "Radio.helpText",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Hint under this option's label, linked with aria-describedby."
    },
    {
      "name": "Radio.size",
      "type": "\"small\" | \"medium\" | \"large\"",
      "default": "from group",
      "required": false,
      "description": "Circle 14 / 16 / 20px with label 12 / 14 / 16. Inherits the RadioGroup size."
    },
    {
      "name": "Radio.isDisabled",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Disables this option only: skipped by Tab and arrow keys, not submitted, 50% opacity."
    },
    {
      "name": "RadioGroup.label",
      "type": "string",
      "default": null,
      "required": true,
      "description": "Legend text that names the group. Rendered as <legend>."
    },
    {
      "name": "RadioGroup.name",
      "type": "string",
      "default": "auto id",
      "required": false,
      "description": "Form field name shared by every option; one value is submitted. Required for forms."
    },
    {
      "name": "RadioGroup.value",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Controlled selected value. Use with onChange; the component never changes its own state when set."
    },
    {
      "name": "RadioGroup.defaultValue",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Initial value when uncontrolled. Ignored if value is set. Unset means nothing is selected."
    },
    {
      "name": "RadioGroup.onChange",
      "type": "({ name: string; value: string; event }) => void",
      "default": null,
      "required": false,
      "description": "Fires when the selection changes (click, label click, arrow key, Space). Not fired for the option that is already selected, or when disabled or read-only. Required when controlled."
    },
    {
      "name": "RadioGroup.isDisabled",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Disables every option: not focusable, not submitted, 50% opacity."
    },
    {
      "name": "RadioGroup.isRequired",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "One option must be selected to submit. Sets required on the inputs."
    },
    {
      "name": "RadioGroup.isReadOnly",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Focusable and submitted, but the value can't change; arrow keys move focus only. Visual treatment is UNDEFINED (gray fill proposed)."
    },
    {
      "name": "RadioGroup.validationState",
      "type": "\"none\" | \"error\"",
      "default": "none",
      "required": false,
      "description": "\"error\" draws the negative border on every option and sets aria-invalid on the group."
    },
    {
      "name": "RadioGroup.errorText",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Shown once under the group when validationState is \"error\"; replaces helpText. Required when validationState=\"error\"."
    },
    {
      "name": "RadioGroup.helpText",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Hint under the group, linked to the fieldset with aria-describedby."
    },
    {
      "name": "RadioGroup.orientation",
      "type": "\"vertical\" | \"horizontal\"",
      "default": "vertical",
      "required": false,
      "description": "Vertical stack (gap spacing-4) or a row for 2-3 short options (gap spacing-7)."
    },
    {
      "name": "RadioGroup.size",
      "type": "\"small\" | \"medium\" | \"large\"",
      "default": "medium",
      "required": false,
      "description": "Passed to every Radio."
    },
    {
      "name": "RadioGroup.necessityIndicator",
      "type": "\"required\" | \"optional\" | \"none\"",
      "default": "none",
      "required": false,
      "description": "Marks the legend as required or optional. Visual treatment: UNDEFINED (none for now)."
    }
  ],
  "undefined": [
    "Pressed fill for a selected circle (--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",
    "necessityIndicator visual (fallback: none; say it in the legend)",
    "Name of the aria-label prop for label-less options",
    "Name of the autoFocus prop",
    "Dot motion (fallback: instant)"
  ],
  "sizes": {
    "circleWidthHeight": "small --size-14 · medium --size-16 · large --size-20",
    "circleBorderRadius": "1px (--border-width-thin) · --border-radius-round",
    "dot": "SVG circle cx 8 cy 8 r 3.5 in a 16 viewBox, fill = dot token, no stroke; scales with the circle (about 5 / 6 / 8px)",
    "circleToLabelGap": "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 circle 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)"
  },
  "states": [
    {
      "name": "default · unselected",
      "trigger": "resting",
      "tokens": {
        "bg": "surface.background.gray.subtle",
        "border": "interactive.border.gray.default",
        "dot": "none"
      }
    },
    {
      "name": "default · selected",
      "trigger": "resting",
      "tokens": {
        "bg": "interactive.background.primary.default",
        "border": "interactive.border.primary.default",
        "dot": "interactive.icon.onPrimary.normal"
      }
    },
    {
      "name": "hover · unselected",
      "trigger": "pointer over the circle or label",
      "tokens": {
        "bg": "surface.background.gray.subtle",
        "border": "interactive.border.gray.highlighted",
        "dot": "none"
      }
    },
    {
      "name": "hover · selected",
      "trigger": "pointer over the circle or label",
      "tokens": {
        "bg": "interactive.background.primary.highlighted",
        "border": "interactive.border.primary.default",
        "dot": "interactive.icon.onPrimary.normal"
      }
    },
    {
      "name": "focus-visible · unselected",
      "trigger": "keyboard focus",
      "tokens": {
        "bg": "surface.background.gray.subtle",
        "border": "interactive.border.primary.default + ring",
        "dot": "none"
      }
    },
    {
      "name": "focus-visible · selected",
      "trigger": "keyboard focus",
      "tokens": {
        "bg": "interactive.background.primary.default",
        "border": "interactive.border.primary.default + ring",
        "dot": "interactive.icon.onPrimary.normal"
      }
    },
    {
      "name": "pressed · unselected",
      "trigger": "pointer down",
      "tokens": {
        "bg": "interactive.background.gray.fadedHighlighted",
        "border": "interactive.border.gray.highlighted",
        "dot": "none"
      }
    },
    {
      "name": "pressed · selected",
      "trigger": "pointer down",
      "tokens": {
        "bg": "UNDEFINED · needs decision (--undefined-interactive-background-primary-pressed)",
        "border": "interactive.border.primary.default",
        "dot": "interactive.icon.onPrimary.normal"
      }
    },
    {
      "name": "disabled · unselected",
      "trigger": "isDisabled",
      "tokens": {
        "bg": "interactive.background.gray.disabled",
        "border": "interactive.border.gray.default",
        "dot": "none (+ opacity 50%)"
      }
    },
    {
      "name": "disabled · selected",
      "trigger": "isDisabled",
      "tokens": {
        "bg": "interactive.background.primary.default",
        "border": "interactive.border.primary.default",
        "dot": "interactive.icon.onPrimary.normal (+ opacity 50%)"
      }
    },
    {
      "name": "read-only · unselected",
      "trigger": "RadioGroup isReadOnly",
      "tokens": {
        "bg": "surface.background.gray.subtle",
        "border": "interactive.border.gray.default",
        "dot": "none"
      }
    },
    {
      "name": "read-only · selected",
      "trigger": "RadioGroup isReadOnly (proposed, not approved)",
      "tokens": {
        "bg": "interactive.background.gray.default",
        "border": "interactive.border.gray.default",
        "dot": "interactive.icon.gray.normal"
      }
    },
    {
      "name": "invalid · unselected",
      "trigger": "RadioGroup validationState=\"error\"",
      "tokens": {
        "bg": "surface.background.gray.subtle",
        "border": "feedback.border.negative.intense",
        "dot": "none"
      }
    },
    {
      "name": "invalid · selected",
      "trigger": "RadioGroup validationState=\"error\"",
      "tokens": {
        "bg": "interactive.background.primary.default",
        "border": "feedback.border.negative.intense",
        "dot": "interactive.icon.onPrimary.normal"
      }
    }
  ],
  "behaviour": {
    "select": "Click on the circle or label, an arrow key, or Space on an unselected group selects the option and fires onChange once. Enter never selects.",
    "reselect": "Clicking the option that is already selected does nothing and fires no onChange.",
    "clear": "The UI can't return a group to none; only the app can reset value to undefined.",
    "controlled": "value set: render it as-is; never change internal state.",
    "uncontrolled": "defaultValue sets the first value; the component owns state afterwards. Unset = nothing selected.",
    "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 the group helpText in the same slot; never both.",
    "groupError": "One message under the group; every option gets the error border; aria-invalid on the group.",
    "disabledGroup": "RadioGroup isDisabled: the whole group leaves the tab order, no change, not sent; opacity 50%.",
    "disabledOption": "Radio isDisabled: skipped by Tab entry and arrow keys; the other options stay usable.",
    "readOnly": "Focusable and sent; clicks, Space and arrows never change the value. Visual: UNDEFINED · needs decision (fallback: gray fill).",
    "requiredMarker": "necessityIndicator visual: UNDEFINED · needs decision. Fallback: none; say it in the legend.",
    "autoFocus": "Focus goes to the selected option, else the first enabled one (approved). Prop name not in the API: UNDEFINED · needs decision.",
    "focusRing": "Only on :focus-visible (keyboard). Mouse and touch never show the ring.",
    "hover": "Circle + label row is the hover target. No hover on touch devices.",
    "pressed": "Shown while the pointer is down; the value changes on release.",
    "labelWrap": "Long labels wrap; the circle stays centred on the first line.",
    "dotAnimation": "Dot motion: UNDEFINED · needs decision. Fallback: instant, no animation."
  },
  "keyboard": [
    {
      "key": "Tab / Shift+Tab",
      "action": "Enter at the selected option, else the first enabled one; next Tab leaves the group."
    },
    {
      "key": "Arrow Down / Right",
      "action": "Next enabled option, selected; wraps last -> first; disabled skipped."
    },
    {
      "key": "Arrow Up / Left",
      "action": "Previous enabled option, selected; wraps first -> last; disabled skipped."
    },
    {
      "key": "Space",
      "action": "Selects the focused option if none is selected; else no-op."
    },
    {
      "key": "Enter",
      "action": "No select; submits the form (native)."
    },
    {
      "key": "Click label",
      "action": "Select + focus the input; no ring (not :focus-visible)."
    }
  ],
  "accessibility": {
    "summary": "Native <input type=\"radio\"> with a shared name gives the keyboard behaviour for free; add no key handlers. Markup: <fieldset><legend> + per option <label><input type=\"radio\"> + help text.",
    "aria": [
      {
        "element": "input",
        "attributes": "type=\"radio\"",
        "when": "Always"
      },
      {
        "element": "input",
        "attributes": "name",
        "when": "RadioGroup name, shared by every option"
      },
      {
        "element": "input",
        "attributes": "checked",
        "when": "RadioGroup value === Radio value"
      },
      {
        "element": "input",
        "attributes": "value",
        "when": "Radio value"
      },
      {
        "element": "input",
        "attributes": "aria-label",
        "when": "label-less options only (prop name UNDEFINED)"
      },
      {
        "element": "input",
        "attributes": "aria-describedby",
        "when": "id of Radio helpText"
      },
      {
        "element": "input",
        "attributes": "required",
        "when": "RadioGroup isRequired"
      },
      {
        "element": "input",
        "attributes": "disabled",
        "when": "Radio or RadioGroup isDisabled"
      },
      {
        "element": "fieldset",
        "attributes": "aria-describedby",
        "when": "id of group helpText, or errorText when invalid"
      },
      {
        "element": "fieldset",
        "attributes": "aria-invalid=\"true\"",
        "when": "validationState = \"error\""
      },
      {
        "element": "legend",
        "attributes": "text",
        "when": "RadioGroup label"
      },
      {
        "element": "radiogroup (custom build only)",
        "attributes": "aria-readonly=\"true\"",
        "when": "isReadOnly"
      }
    ]
  },
  "usage": {
    "do": [
      "Use a native <input type=\"radio\"> with a shared name and a real <label>; keep the input in the accessibility tree.",
      "Keep the 1px interactive/border/primary/default outline on selected circles.",
      "Use only the Theme tokens listed under States; Global tokens only for size, spacing, radius, type.",
      "Wrap options in RadioGroup (fieldset + legend) and show one group error.",
      "Enter the group at the selected option (else the first); arrows move and select, wrap, skip disabled.",
      "Clear the error as soon as the value becomes valid."
    ],
    "dont": [
      "Don't add component tokens (no radio/*); add a Theme token or flag UNDEFINED.",
      "Don't make every option its own tab stop.",
      "Don't show the focus ring on mouse click; use :focus-visible.",
      "Don't select on Enter, or fire onChange for the option that is already selected.",
      "Don't use a lone radio, or radios for more than about 6 options (use Select).",
      "Don't hide the input with display:none or visibility:hidden."
    ]
  },
  "example": "<RadioGroup label=\"Billing cycle\" name=\"cycle\" defaultValue=\"monthly\"><Radio value=\"monthly\">Monthly</Radio><Radio value=\"yearly\" helpText=\"Two months free.\">Yearly</Radio></RadioGroup>"
}
