{
  "package": "@blade-ai/weft",
  "status": "beta",
  "version": "0.1.0",
  "updated": "2026-11-24",
  "component": "Combobox",
  "import": "import { Combobox } from \"@blade-ai/weft/components/combobox\";",
  "docs": "/components/combobox",
  "description": "Searches a long list and picks one option. A trigger opens a popover with a search field and results; three sizes, square, flat and token-driven.",
  "props": [
    {
      "name": "label",
      "type": "string",
      "default": null,
      "required": true,
      "description": "Accessible name of the trigger and of the search input."
    },
    {
      "name": "labelPosition",
      "type": "\"top\" | \"left\"",
      "values": [
        "top",
        "left"
      ],
      "default": "top",
      "required": false,
      "description": "left = 120px label column."
    },
    {
      "name": "placeholder",
      "type": "string",
      "default": "Select…",
      "required": false,
      "description": "Trigger text while the value is empty."
    },
    {
      "name": "searchPlaceholder",
      "type": "string",
      "default": "Search…",
      "required": false,
      "description": "Placeholder of the search input inside the popover."
    },
    {
      "name": "options",
      "type": "{ value, label, isDisabled? }[]",
      "default": null,
      "required": true,
      "description": "Rendered as option rows. Grouping key: UNDEFINED · needs decision."
    },
    {
      "name": "value · defaultValue · onValueChange",
      "type": "string · (value) => void",
      "default": null,
      "required": false,
      "description": "Single value. Multi-select is not in the spec."
    },
    {
      "name": "inputValue · onInputChange",
      "type": "string · (query) => void",
      "default": "",
      "required": false,
      "description": "Controlled query (needed for async). UNDEFINED · needs decision."
    },
    {
      "name": "filter",
      "type": "(value, search) => number",
      "default": "contains",
      "required": false,
      "description": "Return 0 to hide an option; higher ranks first. Default rule for Blade AI (contains vs starts-with): UNDEFINED · needs decision. Fallback: case-insensitive contains, starts-with ranked first."
    },
    {
      "name": "emptyText",
      "type": "string",
      "default": "No results found.",
      "required": false,
      "description": "Copy for an empty list; pattern \"No <noun> found.\"."
    },
    {
      "name": "size",
      "type": "\"small\" | \"medium\" | \"large\"",
      "values": [
        "small",
        "medium",
        "large"
      ],
      "default": "medium",
      "required": false,
      "description": "Trigger only; the search input and options stay medium / 32px on desktop."
    },
    {
      "name": "validationState",
      "type": "\"none\" | \"success\" | \"error\"",
      "values": [
        "none",
        "success",
        "error"
      ],
      "default": "none",
      "required": false,
      "description": "error → aria-invalid + errorText. One message at a time."
    },
    {
      "name": "helpText · successText · errorText",
      "type": "string",
      "default": null,
      "required": false,
      "description": "One message at a time; error replaces help."
    },
    {
      "name": "isRequired · isDisabled",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Required sets aria-required; disabled is native."
    },
    {
      "name": "isReadOnly · isLoading",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Not in Blade: UNDEFINED · needs decision. Read-only is focusable and cannot open; loading shows a spinner and cannot open (fallback)."
    },
    {
      "name": "isClearable · allowsCustomValue",
      "type": "boolean",
      "default": null,
      "required": false,
      "description": "Not built: UNDEFINED · needs decision (no clear button on the trigger, no free-text value)."
    },
    {
      "name": "isOpen · defaultOpen · onOpenChange",
      "type": "boolean · (open) => void",
      "default": false,
      "required": false,
      "description": "Controlled popover state."
    },
    {
      "name": "name",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Hidden input carrying the value for form submit."
    }
  ],
  "states": [
    {
      "name": "trigger · empty",
      "trigger": "Value empty, closed",
      "tokens": "border interactive.border.gray.default · bg surface.background.gray.subtle · text surface.text.gray.muted · icon surface.icon.gray.muted (chevrons-up-down)",
      "notes": "Placeholder shown."
    },
    {
      "name": "trigger · filled",
      "trigger": "Value set, closed",
      "tokens": "text surface.text.gray.normal · border interactive.border.gray.default · bg surface.background.gray.subtle",
      "notes": "Shows the option label. Clear button: UNDEFINED · needs decision."
    },
    {
      "name": "trigger · hover",
      "trigger": "Pointer over trigger",
      "tokens": "border interactive.border.gray.highlighted",
      "notes": "No ring."
    },
    {
      "name": "trigger · focus-visible",
      "trigger": "Keyboard focus, closed",
      "tokens": "border interactive.border.primary.default · ring 0 0 0 3px interactive.border.primary.faded",
      "notes": "Keyboard only."
    },
    {
      "name": "trigger · open",
      "trigger": "Popover shown, focus in the search input",
      "tokens": "border interactive.border.primary.default · popup bg popup.background.gray.subtle",
      "notes": "aria-expanded=\"true\"; no ring."
    },
    {
      "name": "search input · typing",
      "trigger": "Query not empty; results filter",
      "tokens": "border interactive.border.primary.default · ring interactive.border.primary.faded · text surface.text.gray.normal · icon interactive.icon.gray.muted · clear interactive.icon.gray.muted (hover interactive.icon.gray.normal)",
      "notes": "Matched characters use interactive.text.gray.normal, the rest interactive.text.gray.muted."
    },
    {
      "name": "field · disabled",
      "trigger": "isDisabled",
      "tokens": "bg interactive.background.gray.disabled · border interactive.border.gray.default · opacity opacity.600",
      "notes": "No hover, no focus, popover cannot open."
    },
    {
      "name": "field · read-only",
      "trigger": "isReadOnly",
      "tokens": "opacity.0 on chevrons · other tokens UNDEFINED · needs decision",
      "notes": "Focusable, cannot open. Fallback uses surface.border.gray.muted."
    },
    {
      "name": "field · loading",
      "trigger": "isLoading",
      "tokens": "icon surface.icon.gray.muted (spinner)",
      "notes": "aria-busy=\"true\". Opening while loading: UNDEFINED · needs decision."
    },
    {
      "name": "field · invalid",
      "trigger": "validationState = error",
      "tokens": "border feedback.border.negative.intense · text feedback.text.negative.intense",
      "notes": "aria-invalid=\"true\"; error replaces help."
    },
    {
      "name": "field · success",
      "trigger": "validationState = success",
      "tokens": "border interactive.border.gray.default · text feedback.text.positive.intense + check",
      "notes": "Success border / bg: UNDEFINED · needs decision."
    },
    {
      "name": "option · default",
      "trigger": "In results, query empty",
      "tokens": "text interactive.text.gray.normal · min-height size.32 · gap spacing.3",
      "notes": "role=\"option\"; check slot reserved, hidden."
    },
    {
      "name": "option · highlighted",
      "trigger": "Pointer hover or ↓ / ↑",
      "tokens": "bg interactive.background.gray.default",
      "notes": "data-selected; aria-activedescendant on the input."
    },
    {
      "name": "option · selected",
      "trigger": "option.value === value",
      "tokens": "bg interactive.background.primary.faded · check interactive.icon.gray.normal · opacity.1300",
      "notes": "aria-selected=\"true\"."
    },
    {
      "name": "option · disabled",
      "trigger": "option.isDisabled",
      "tokens": "text interactive.text.gray.disabled",
      "notes": "aria-disabled=\"true\"."
    },
    {
      "name": "no results",
      "trigger": "Query matches nothing",
      "tokens": "text surface.text.gray.muted",
      "notes": "emptyText, announced through a live region. Loading-results copy and spinner: UNDEFINED."
    }
  ],
  "sizes": [
    {
      "property": "Trigger height",
      "value": "32 · 36 · 48",
      "token": "size.32 · size.36 · size.48"
    },
    {
      "property": "Padding-x · gap",
      "value": "8 · 6 (small) / 12 · 8",
      "token": "spacing.3 · spacing.15 (small) / spacing.4 · spacing.3"
    },
    {
      "property": "Font",
      "value": "13 · 13 · 14",
      "token": "fonts.size.1200 · fonts.size.1200 · fonts.size.100"
    },
    {
      "property": "Icon",
      "value": "14 · 16 · 16",
      "token": "size.14 · size.16 · size.16"
    },
    {
      "property": "Menu · option",
      "value": "option 32 · menu max 240 · padding 4",
      "token": "size.32 · size.240 · spacing.2"
    },
    {
      "property": "Mobile drawer option",
      "value": "48 shown",
      "token": "UNDEFINED · needs decision"
    }
  ],
  "behaviour": {
    "open triggers": "Click / tap on the trigger; Enter, Space or ↓ when it has focus. Opening moves focus into the search input with an empty query and highlights the selected option (or the first). Hover never opens.",
    "filtering": "Case-insensitive, on the option label, via the filter prop. Contains vs starts-with for Blade AI: UNDEFINED · needs decision. Fallback: contains, starts-with ranked first.",
    "debounce": "Local options filter on every keystroke. Debounce for remote search: UNDEFINED · needs decision.",
    "async loading": "Not built. Proposed: inputValue + onInputChange drive a fetch; UNDEFINED · needs decision.",
    "no results": "Shows emptyText; Enter does nothing; the live region announces \"No results\".",
    "free text vs must-select": "Must select from the list: the query never becomes the value. allowsCustomValue / create option: UNDEFINED · needs decision.",
    "blur with unmatched text": "Outside click, Tab or Esc closes the popover and discards the query; value unchanged; no validation error is raised.",
    "clearing": "The clear button in the search input empties the query and keeps focus in the input. Clearing the selected value: UNDEFINED · needs decision.",
    "input text vs selected label": "The trigger always shows the selected option's label (or the placeholder). The query resets to \"\" each time the popover opens.",
    "close on select": "Click or Enter on an option sets value, fires onValueChange, closes the popover and returns focus to the trigger.",
    "multi-select": "Out of scope for this spec.",
    "placement · scroll": "Popover below the trigger, offset spacing.2 (4), width = trigger width, flips above when space is short. Results scroll past size.240.",
    "validation · error clearing": "Validate on close (blur) or submit; re-validate on every change and clear the error as soon as a valid option is selected.",
    "paste": "Pasted text in the search input becomes the query unchanged.",
    "autoFocus": "Targets the main text field; never opens the popover.",
    "mobile": "< 768px: search and results open in a Drawer (bottom sheet). Not built: UNDEFINED · needs decision (no Drawer component)."
  },
  "keyboard": [
    {
      "key": "ArrowDown (closed)",
      "action": "Opens and highlights the selected option (or the first). ArrowUp when closed: UNDEFINED · needs decision."
    },
    {
      "key": "ArrowDown / ArrowUp (open)",
      "action": "Moves the highlight one enabled result; focus stays in the input. Wrap: UNDEFINED · needs decision (fallback: stop at the ends)."
    },
    {
      "key": "Home / End (open)",
      "action": "Caret to start / end of the query (native). Highlight first / last result: UNDEFINED · needs decision."
    },
    {
      "key": "Printable characters",
      "action": "Closed: no typeahead (opening on type: UNDEFINED · needs decision). Open: edit the query, filter, highlight the first match, announce the count."
    },
    {
      "key": "Enter",
      "action": "Closed: opens (Space too). Open: selects the highlighted option, closes, focus to the trigger. No results: nothing."
    },
    {
      "key": "Escape",
      "action": "Closes, value unchanged, query discarded, focus to the trigger. Two-step (clear query first): UNDEFINED · needs decision."
    },
    {
      "key": "Tab / Shift+Tab",
      "action": "Closed: next / previous field. Open: closes without selecting; query discarded; focus moves on."
    },
    {
      "key": "Backspace",
      "action": "Deletes query characters; on an empty query does nothing. Clearing the value: UNDEFINED · needs decision."
    }
  ],
  "accessibility": {
    "summary": "A button trigger opens a popover whose search input is the combobox; the result list is a listbox.",
    "aria": [
      {
        "element": "Trigger",
        "attributes": "<button> · aria-haspopup=\"listbox\" · aria-expanded · aria-controls → listbox id · aria-labelledby → label",
        "when": "Always. Which element carries role=\"combobox\": UNDEFINED · needs decision (WAI-ARIA puts it on the input)."
      },
      {
        "element": "Search input",
        "attributes": "role=\"combobox\" · aria-expanded=\"true\" · aria-controls → listbox id · aria-autocomplete=\"list\" · aria-activedescendant → highlighted option id · aria-labelledby → label",
        "when": "Popover open"
      },
      {
        "element": "Result list",
        "attributes": "role=\"listbox\" · id · aria-labelledby → label · aria-busy while loading",
        "when": "Popover open"
      },
      {
        "element": "Option",
        "attributes": "role=\"option\" · id · aria-selected · aria-disabled · data-selected (highlight)",
        "when": "Each result. Check icon aria-hidden; match spans are presentational."
      },
      {
        "element": "Result count live region",
        "attributes": "visually hidden · role=\"status\" · aria-live=\"polite\" · aria-atomic=\"true\"",
        "when": "After filtering. Exact copy: UNDEFINED · needs decision."
      },
      {
        "element": "Empty text",
        "attributes": "plain text inside the popover (not an option)",
        "when": "Query matches nothing"
      },
      {
        "element": "Trigger (field)",
        "attributes": "aria-describedby → help / error · aria-invalid · aria-required · aria-disabled",
        "when": "Matching state"
      }
    ]
  },
  "usage": {
    "do": [
      "Use Combobox for long lists (15+) or when users know what to type; Select for 5–15; Radio group for 3–4.",
      "Always set emptyText (\"No framework found.\") and keep the selected label visible in the trigger.",
      "Bind only Theme and Global token names (no component tokens).",
      "Announce the result count politely and keep focus in the search input while the highlight moves."
    ],
    "dont": [
      "Use Combobox for 3–4 options, or let the typed query stand in for a value.",
      "Rely on the match highlight alone to show results, or hide disabled matches without a reason.",
      "Hard-code colours or radii, add component copies of Theme tokens, or add multi-select / create-option without a decision."
    ]
  },
  "example": "<Combobox label=\"Framework\" options={[{ value: \"next\", label: \"Next.js\" }, { value: \"remix\", label: \"Remix\" }]} emptyText=\"No framework found.\" onValueChange={setFramework} />"
}
