{
  "package": "@blade-ai/weft",
  "status": "stable",
  "version": "0.1.0",
  "updated": "2026-11-24",
  "component": "SearchInput",
  "import": "import { SearchInput } from \"@blade-ai/weft/components/search-input\";",
  "iconsImport": "import { SearchIcon } from \"@blade-ai/weft/components/icons\";",
  "docs": "/components/search-input",
  "description": "A single-line field for finding items by typing a keyword, inside a role=\"search\" form. Live (debounced) or submit-only; three sizes, clear button, loading and a shortcut hint.",
  "props": [
    {
      "name": "label",
      "type": "string",
      "default": null,
      "required": true,
      "description": "Accessible name. Shown when labelPosition is set, otherwise rendered as aria-label."
    },
    {
      "name": "labelPosition",
      "type": "\"top\" | \"left\"",
      "values": [
        "top",
        "left"
      ],
      "default": null,
      "required": false,
      "description": "Visible label above or to the left. Omit in toolbars."
    },
    {
      "name": "placeholder",
      "type": "string",
      "default": "Search",
      "required": false,
      "description": "Names what can be searched."
    },
    {
      "name": "value · defaultValue",
      "type": "string",
      "default": "\"\"",
      "required": false,
      "description": "Query, controlled or uncontrolled. Kept after searching so users can refine it."
    },
    {
      "name": "searchOn",
      "type": "\"change\" | \"submit\"",
      "values": [
        "change",
        "submit"
      ],
      "default": "change",
      "required": false,
      "description": "Live (debounced onChange) vs Enter only."
    },
    {
      "name": "debounceMs",
      "type": "number",
      "default": 300,
      "required": false,
      "description": "Delay before onChange fires in live mode."
    },
    {
      "name": "minQueryLength",
      "type": "number",
      "default": null,
      "required": false,
      "description": "Characters before onChange / onSubmit fire. UNDEFINED · needs decision; no minimum until decided."
    },
    {
      "name": "onChange",
      "type": "(value: string) => void",
      "default": null,
      "required": false,
      "description": "Debounced; not called below minQueryLength. Clear calls it with \"\" immediately."
    },
    {
      "name": "onSubmit",
      "type": "(value: string) => void",
      "default": null,
      "required": false,
      "description": "Enter; flushes a pending debounce."
    },
    {
      "name": "onClear",
      "type": "() => void",
      "default": null,
      "required": false,
      "description": "Clear button or Esc; value becomes \"\" and focus returns to the input."
    },
    {
      "name": "isLoading",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Spinner replaces the clear button; the form is aria-busy. Editable while loading: UNDEFINED · needs decision (stays editable)."
    },
    {
      "name": "isSearchIconVisible",
      "type": "boolean",
      "default": true,
      "required": false,
      "description": "Leading search icon."
    },
    {
      "name": "shortcut",
      "type": "string | null",
      "default": null,
      "required": false,
      "description": "Global key that focuses the input; shown as a hint while empty and not focused."
    },
    {
      "name": "resultCount",
      "type": "number",
      "default": null,
      "required": false,
      "description": "Text for the polite live region (\"12 results\", \"No results for …\")."
    },
    {
      "name": "size",
      "type": "\"small\" | \"medium\" | \"large\"",
      "values": [
        "small",
        "medium",
        "large"
      ],
      "default": "medium",
      "required": false,
      "description": "Height 32 / 36 / 48px."
    },
    {
      "name": "isDisabled",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "disabled attribute; clear and hint hidden."
    },
    {
      "name": "isReadOnly",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "readonly attribute; no clear."
    },
    {
      "name": "isInvalid · errorText",
      "type": "boolean · string",
      "default": "false · —",
      "required": false,
      "description": "aria-invalid + describedby. Trigger and copy: UNDEFINED · needs decision."
    },
    {
      "name": "autoFocus · name · testID",
      "type": "boolean · string · string",
      "default": null,
      "required": false,
      "description": "Passed to <input>."
    }
  ],
  "states": [
    {
      "name": "empty",
      "trigger": "value = \"\"",
      "tokens": "surface.background.gray.subtle · interactive.border.gray.default · surface.text.gray.muted · surface.icon.gray.muted",
      "notes": "No clear; hint only if shortcut set."
    },
    {
      "name": "typing",
      "trigger": "Focused, value changing",
      "tokens": "interactive.border.primary.default · interactive.border.primary.faded · surface.text.gray.normal · interactive.icon.gray.muted",
      "notes": "onChange after debounceMs."
    },
    {
      "name": "filled",
      "trigger": "value ≠ \"\", blurred",
      "tokens": "surface.text.gray.normal · interactive.icon.gray.muted · size.14",
      "notes": "Clear visible."
    },
    {
      "name": "hover",
      "trigger": "Pointer over field / clear",
      "tokens": "interactive.border.gray.highlighted · interactive.icon.gray.normal",
      "notes": "—"
    },
    {
      "name": "focus-visible",
      "trigger": "Keyboard focus",
      "tokens": "interactive.border.primary.default · interactive.border.primary.faded (3px box-shadow)",
      "notes": "\"/\" hint hidden."
    },
    {
      "name": "disabled",
      "trigger": "isDisabled",
      "tokens": "interactive.background.gray.disabled · opacity.600",
      "notes": "Clear + hint hidden; shortcut inactive."
    },
    {
      "name": "read-only",
      "trigger": "isReadOnly",
      "tokens": "interactive.background.gray.disabled · surface.text.gray.normal",
      "notes": "No clear. Read-only look: UNDEFINED · needs decision (drawn with the disabled background, full opacity)."
    },
    {
      "name": "loading",
      "trigger": "isLoading",
      "tokens": "surface.icon.gray.muted · size.14",
      "notes": "Spinner replaces clear. Editable while loading: UNDEFINED · needs decision."
    },
    {
      "name": "invalid",
      "trigger": "isInvalid",
      "tokens": "feedback.border.negative.intense (border + message)",
      "notes": "Trigger + copy UNDEFINED · needs decision."
    },
    {
      "name": "shortcut hint",
      "trigger": "shortcut set, empty, not focused",
      "tokens": "surface.text.gray.muted · typography.fonts.family.code",
      "notes": "\"/\" (Blade); hidden on touch."
    },
    {
      "name": "results count",
      "trigger": "resultCount changes",
      "tokens": "no visual token (visually hidden live region)",
      "notes": "\"12 results\" / \"No results for …\". Copy: UNDEFINED · needs decision."
    }
  ],
  "sizes": [
    {
      "property": "Height",
      "value": "32 / 36 / 48px",
      "token": "size.32 · size.36 · size.48 (Blade: 40 large)"
    },
    {
      "property": "Padding-x",
      "value": "8 / 12 / 12px",
      "token": "spacing.3 · spacing.4"
    },
    {
      "property": "Gap",
      "value": "6 / 8 / 8px",
      "token": "spacing.15 · spacing.3"
    },
    {
      "property": "Search icon",
      "value": "14 / 16 / 16px",
      "token": "size.14 · size.16"
    },
    {
      "property": "Clear · spinner",
      "value": "14px all sizes",
      "token": "size.14; hit target: UNDEFINED · needs decision"
    },
    {
      "property": "Query font",
      "value": "13 / 13 / 14px",
      "token": "fonts.size.1200 · fonts.size.100 · lineHeights.100"
    },
    {
      "property": "Shortcut hint",
      "value": "mono, 13px",
      "token": "fonts.family.code · fonts.size.1200"
    },
    {
      "property": "Border · ring · radius",
      "value": "1px · 3px · 0",
      "token": "border.width.thin · interactive.border.primary.faded + border.width.3 · border.radius.none"
    }
  ],
  "behaviour": {
    "live": "searchOn=\"change\": onChange fires debounceMs (300) after the last keystroke. Results update in place; focus stays in the field.",
    "submit": "searchOn=\"submit\": only Enter calls onSubmit. In live mode Enter flushes the debounce and also calls onSubmit.",
    "minQuery": "Below minQueryLength no search fires. Value UNDEFINED · needs decision; whether \"\" restores the full list: UNDEFINED · needs decision.",
    "clear": "Clear button rendered only when value ≠ \"\" and not disabled / read-only / loading. Click: value \"\", onClear(), onChange(\"\") immediately (no debounce), focus returns to the input.",
    "escape": "First Esc with a value: same as clear (focus stays). Second Esc, or empty: blur the field.",
    "nativeClear": "The native type=search clear is hidden; only our clear button is shown.",
    "loading": "isLoading swaps clear for the spinner; the query stays in the field. Last request wins.",
    "shortcut": "Global keydown of shortcut (\"/\") focuses and selects the input, unless focus is already in a text field; preventDefault so \"/\" is not typed.",
    "paste": "Paste is kept as-is (no format). Never block paste.",
    "autoFocus": "autoFocus targets the search input itself, never the clear button or search icon.",
    "persistence": "Keep the query after searching so users can refine it. Sync to URL: UNDEFINED · needs decision."
  },
  "keyboard": [
    {
      "key": "/",
      "action": "Focuses the search from anywhere (not inside text fields) when shortcut=\"/\"."
    },
    {
      "key": "Enter",
      "action": "Submits the search (onSubmit)."
    },
    {
      "key": "Esc",
      "action": "Clears the query (first press) or leaves the field."
    },
    {
      "key": "Tab",
      "action": "Field → clear button (when shown) → next element."
    },
    {
      "key": "Enter / Space on clear",
      "action": "Clears and returns focus to the input."
    }
  ],
  "accessibility": {
    "summary": "Native search input inside a role=\"search\" landmark; the <input> carries name, description and state.",
    "aria": [
      {
        "element": "<form> container",
        "attributes": "role=\"search\" (landmark)",
        "when": "Always"
      },
      {
        "element": "<input>",
        "attributes": "type=\"search\" · autocomplete=\"off\"",
        "when": "Always; native cancel button hidden"
      },
      {
        "element": "<input>",
        "attributes": "aria-label = label",
        "when": "No visible label (labelPosition unset)"
      },
      {
        "element": "<label>",
        "attributes": "htmlFor → input id",
        "when": "labelPosition is set"
      },
      {
        "element": "Clear <button>",
        "attributes": "type=\"button\" · aria-label=\"Clear search\"",
        "when": "value ≠ \"\""
      },
      {
        "element": "Live region",
        "attributes": "role=\"status\" · aria-live=\"polite\" · visually hidden",
        "when": "resultCount is set"
      },
      {
        "element": "Spinner · form",
        "attributes": "spinner aria-hidden · form aria-busy=\"true\"",
        "when": "isLoading"
      },
      {
        "element": "Shortcut hint",
        "attributes": "aria-hidden · input aria-keyshortcuts=\"/\"",
        "when": "shortcut set"
      },
      {
        "element": "<input>",
        "attributes": "aria-invalid=\"true\" · aria-describedby → message",
        "when": "isInvalid"
      }
    ]
  },
  "usage": {
    "do": [
      "Place the search at the start of the toolbar above what it searches.",
      "Say what can be searched: \"Search payments, customers or IDs\".",
      "Always give an accessible name; the field is wrapped in role=\"search\".",
      "Show a result for every search: rows, loading or an Empty State with a way out."
    ],
    "dont": [
      "Add two search fields for the same content.",
      "Rely on the placeholder as the only label.",
      "Leave a blank area after a search.",
      "Show the native WebKit clear next to ours, or the \"/\" hint on touch."
    ]
  },
  "example": "<SearchInput label=\"Search payments\" placeholder=\"Search payments, customers or IDs\" shortcut=\"/\" onChange={setQuery} onSubmit={runSearch} resultCount={results.length} />"
}
