{
  "package": "@blade-ai/weft",
  "status": "beta",
  "version": "0.1.0",
  "updated": "2026-11-24",
  "component": "NumberInput",
  "import": "import { NumberInput } from \"@blade-ai/weft/components/number-input\";",
  "docs": "/components/number-input",
  "description": "Sets a whole number inside a range by typing it or stepping with − and +, such as seats on a plan. Three sizes; square, flat and token-driven.",
  "props": [
    {
      "name": "label",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Visible text above the field, rendered as a <label> tied to the input. Required unless accessibilityLabel is passed."
    },
    {
      "name": "accessibilityLabel",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Name when there is no visible label (cart and table rows). Becomes aria-label."
    },
    {
      "name": "value",
      "type": "number",
      "default": null,
      "required": false,
      "description": "Controlled value. Use with onChange. Sets aria-valuenow."
    },
    {
      "name": "defaultValue",
      "type": "number",
      "default": null,
      "required": false,
      "description": "Initial value when uncontrolled. Ignored if value is set. Defaults to min."
    },
    {
      "name": "min",
      "type": "number",
      "default": 0,
      "required": false,
      "description": "Lowest value. − and Down stop here; Home jumps here. Sets aria-valuemin."
    },
    {
      "name": "max",
      "type": "number",
      "default": null,
      "required": true,
      "description": "Highest value. + and Up stop here; End jumps here. Sets aria-valuemax. Always set it."
    },
    {
      "name": "step",
      "type": "number",
      "default": 1,
      "required": false,
      "description": "Amount added or removed by −, +, Up and Down. Greater than 0."
    },
    {
      "name": "largeStep",
      "type": "number",
      "default": 10,
      "required": false,
      "description": "Amount for PageUp and PageDown. Default amount: UNDEFINED · needs decision (10 proposed)."
    },
    {
      "name": "onChange",
      "type": "({ value, name, event }) => void",
      "default": null,
      "required": false,
      "description": "Fires with the new number after typing, a ± press or a step key. Not fired when disabled or read-only. Required when controlled."
    },
    {
      "name": "name",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Form field name. The number is sent with the form."
    },
    {
      "name": "size",
      "type": "\"small\" | \"medium\" | \"large\"",
      "values": [
        "small",
        "medium",
        "large"
      ],
      "default": "medium",
      "required": false,
      "description": "Height 32 · 36 · 48 with value text 12 · 14 · 16."
    },
    {
      "name": "helpText",
      "type": "ReactNode",
      "default": null,
      "required": false,
      "description": "Hint under the field, linked with aria-describedby. State the range here."
    },
    {
      "name": "errorText",
      "type": "ReactNode",
      "default": null,
      "required": false,
      "description": "Shown when validationState is \"error\"; replaces helpText."
    },
    {
      "name": "validationState",
      "type": "\"none\" | \"error\"",
      "values": [
        "none",
        "error"
      ],
      "default": "none",
      "required": false,
      "description": "\"error\" draws the negative border and sets aria-invalid."
    },
    {
      "name": "isDisabled",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Not focusable, not submitted, 50% opacity. ± buttons are inert."
    },
    {
      "name": "isReadOnly",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Focusable and submitted, but the value cannot change; ± and step keys do nothing. Sets aria-readonly=\"true\". Visual treatment: UNDEFINED · needs decision."
    },
    {
      "name": "isRequired",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Must hold a value to submit. Sets aria-required. Visual marker: UNDEFINED · needs decision."
    },
    {
      "name": "autoFocus",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Focuses the value text field on mount, never a ± button."
    },
    {
      "name": "testID",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Test selector on the input (data-testid)."
    }
  ],
  "states": [
    {
      "name": "default · field",
      "trigger": "First render, not focused",
      "tokens": "bg surface.background.gray.subtle · border interactive.border.gray.default · value interactive.text.gray.normal",
      "notes": "Field is square: border.radius.none, border 1px."
    },
    {
      "name": "default · − / + buttons",
      "trigger": "Always, inside the field",
      "tokens": "bg interactive.background.gray.faded · icon interactive.icon.gray.normal · divider surface.border.gray.muted",
      "notes": "Dividers are 1px, inside the field border."
    },
    {
      "name": "hover",
      "trigger": "Pointer over any part",
      "tokens": "field border interactive.border.gray.highlighted · hovered button bg interactive.background.gray.fadedHighlighted",
      "notes": "Only the button under the pointer fills. No ring. No hover on touch devices."
    },
    {
      "name": "focus-visible",
      "trigger": "Keyboard focus on the value field",
      "tokens": "border interactive.border.primary.default · ring 0 0 0 3px interactive.border.primary.faded",
      "notes": "Only on :focus-visible on the field. ± buttons never take focus, so never show a ring."
    },
    {
      "name": "pressed",
      "trigger": "Pointer down on − or +",
      "tokens": "button bg undefined.interactive.background.gray.pressed · field border interactive.border.gray.highlighted",
      "notes": "UNDEFINED · needs decision: uses the existing placeholder token --undefined-interactive-background-gray-pressed."
    },
    {
      "name": "disabled",
      "trigger": "isDisabled",
      "tokens": "bg interactive.background.gray.disabled · border interactive.border.gray.default · opacity opacity.600 on label, field and help",
      "notes": "Not focusable, no hover, ± inert."
    },
    {
      "name": "read-only",
      "trigger": "isReadOnly",
      "tokens": "field bg interactive.background.gray.faded * · border surface.border.gray.muted · ± bg none · ± icon interactive.icon.gray.muted *",
      "notes": "UNDEFINED · needs decision: read-only treatment is proposed, not approved; hiding ± is also open."
    },
    {
      "name": "invalid",
      "trigger": "validationState = \"error\"",
      "tokens": "border feedback.border.negative.intense · error text feedback.text.negative.intense",
      "notes": "errorText replaces helpText in the same slot; never both."
    },
    {
      "name": "at min · − button",
      "trigger": "value = min",
      "tokens": "bg interactive.background.gray.disabled · icon interactive.icon.gray.disabled (new)",
      "notes": "aria-disabled=\"true\"; the field stays focusable."
    },
    {
      "name": "at max · + button",
      "trigger": "value = max",
      "tokens": "bg interactive.background.gray.disabled · icon interactive.icon.gray.disabled (new)",
      "notes": "aria-disabled=\"true\"; the field stays focusable."
    }
  ],
  "sizes": [
    {
      "property": "Height · ± width",
      "value": "32 · 36 · 48",
      "token": "size.32 · size.36 · size.48"
    },
    {
      "property": "Value width",
      "value": "40 · 48 · 48",
      "token": "size.40 · size.48 · size.48"
    },
    {
      "property": "Icon size · stroke (viewBox 16)",
      "value": "14 · 16 · 20 · 1.5 · 1.5 · 1.25",
      "token": "size.14 · size.16 · size.20"
    },
    {
      "property": "Border · radius",
      "value": "1px · 0",
      "token": "border.width.thin · border.radius.none"
    },
    {
      "property": "Value font size / line height",
      "value": "12/16 · 14/20 · 16/22",
      "token": "fonts.size.75 · 100 · 200 / lineHeights.50 · 100 · 1200"
    },
    {
      "property": "Label font size · weight",
      "value": "14 · medium",
      "token": "fonts.size.100 · fonts.weight.medium"
    },
    {
      "property": "Label → field and field → help gap",
      "value": "6",
      "token": "spacing.15"
    },
    {
      "property": "Help / error font size / line height",
      "value": "12/16",
      "token": "fonts.size.75 / lineHeights.50"
    },
    {
      "property": "Touch target on mobile",
      "value": "48 on large (± squares)",
      "token": "size.48"
    }
  ],
  "behaviour": {
    "step": "−, +, Up and Down change the value by step; the result stays inside min to max; fires onChange.",
    "large step": "PageUp / PageDown change it by largeStep. Default largeStep: UNDEFINED · needs decision. Fallback: 10.",
    "home / end": "Home sets min; End sets max.",
    "at min / at max": "value = min → − disabled (aria-disabled); value = max → + disabled. The field stays focusable.",
    "typing": "Digits only (and a leading minus when min < 0). Paste strips non-numeric characters (approved field rule).",
    "clamping": "Clamp on blur vs on type: UNDEFINED · needs decision. Fallback: clamp on blur.",
    "empty field": "Empty on blur: UNDEFINED · needs decision. Fallback: restore the last valid value.",
    "press-and-hold": "Repeat while ± is held: UNDEFINED · needs decision. Fallback: one step per press.",
    "controlled": "value set → render it as-is; never change internal state.",
    "uncontrolled": "defaultValue sets the first value; component owns state afterwards.",
    "validation · show": "App sets validationState=\"error\" + errorText. First trigger (on blur vs on submit): UNDEFINED · needs decision. Fallback: on submit.",
    "validation · clear": "Re-validate on every change; once valid, the error clears immediately (approved field rule).",
    "error vs help": "errorText replaces helpText in the same slot; never both.",
    "disabled": "Not focusable, no hover, ± inert, not sent with the form; opacity 50%.",
    "read-only": "Focusable, sent with the form, value can't change. Visual: UNDEFINED · needs decision (fallback: faded fill, muted ±).",
    "required marker": "Visible \"required\" marker: UNDEFINED · needs decision. Fallback: none; say it in the label.",
    "autoFocus": "Focus lands on the value text field, never on − or +.",
    "focus ring": "Only on :focus-visible on the field. ± never take focus, so never show a ring.",
    "hover": "Field border darkens; only the ± button under the pointer fills. No hover on touch devices.",
    "pressed": "± shows the pressed fill while the pointer is down; one step per click.",
    "value motion": "Value change motion: UNDEFINED · needs decision. Fallback: instant, no animation."
  },
  "keyboard": [
    {
      "key": "Tab / Shift+Tab",
      "action": "To / from the value field; ± skipped (tabindex=\"-1\"); disabled skipped, read-only kept."
    },
    {
      "key": "Up / Down",
      "action": "+ step / − step, kept inside min to max. No-op when read-only or disabled."
    },
    {
      "key": "PageUp / PageDown",
      "action": "+ largeStep / − largeStep, kept inside min to max."
    },
    {
      "key": "Home / End",
      "action": "Set min / set max."
    },
    {
      "key": "Digits / paste",
      "action": "Edit as text; paste strips non-numeric characters."
    },
    {
      "key": "Enter",
      "action": "Submits the form (native)."
    },
    {
      "key": "Click − / +",
      "action": "One step; focus stays where it was."
    }
  ],
  "accessibility": {
    "summary": "The value field handles keys as role=\"spinbutton\"; the ± buttons add no key handlers and are not tab stops.",
    "aria": [
      {
        "element": "<input>",
        "attributes": "role=\"spinbutton\" · inputmode=\"numeric\" · aria-valuenow · aria-valuemin · aria-valuemax",
        "when": "Always"
      },
      {
        "element": "<input>",
        "attributes": "<label for> or aria-label = accessibilityLabel",
        "when": "label · accessibilityLabel (only when there is no label)"
      },
      {
        "element": "<input>",
        "attributes": "aria-describedby = id of helpText, or of errorText when invalid",
        "when": "Help or error text shown"
      },
      {
        "element": "<input>",
        "attributes": "aria-invalid=\"true\"",
        "when": "validationState = error"
      },
      {
        "element": "<input>",
        "attributes": "aria-readonly=\"true\" · aria-required=\"true\" · disabled",
        "when": "isReadOnly · isRequired · isDisabled"
      },
      {
        "element": "Decrease button",
        "attributes": "aria-label=\"Decrease\" (+ label, e.g. \"Decrease seats\") · tabindex=\"-1\"",
        "when": "Always"
      },
      {
        "element": "Increase button",
        "attributes": "aria-label=\"Increase\" (+ label, e.g. \"Increase seats\") · tabindex=\"-1\"",
        "when": "Always"
      },
      {
        "element": "± button",
        "attributes": "aria-disabled=\"true\"",
        "when": "− at min, + at max"
      }
    ]
  },
  "usage": {
    "do": [
      "Use role=\"spinbutton\" or <input type=\"number\"> with a real <label> and aria-valuenow, aria-valuemin, aria-valuemax.",
      "Always set min and max, and state the range in help text.",
      "Keep − and + out of the tab order (tabindex=\"-1\") and name them \"Decrease\" and \"Increase\".",
      "Disable − at min and + at max, drawn with --interactive-icon-gray-disabled.",
      "Use only the Theme tokens listed under States; Global tokens only for size, spacing, radius, type.",
      "Clear the error as soon as the value becomes valid; strip non-numeric characters on paste."
    ],
    "dont": [
      "Don't add component tokens (no numberInput/*); add a Theme token or flag UNDEFINED.",
      "Don't round the field or the buttons: Weft uses --border-radius-none.",
      "Don't show the focus ring on mouse click; use :focus-visible on the field.",
      "Don't make − and + tab stops, or move focus to them on click.",
      "Don't use Number Input for amounts, IDs or named options; use Text input or Select.",
      "Don't replace the value input with plain text; the value must stay typeable."
    ]
  },
  "example": "<NumberInput label=\"Seats\" min={1} max={50} defaultValue={5} helpText=\"Between 1 and 50 seats.\" onChange={({ value }) => setSeats(value)} />"
}
