{"name":"combobox","title":"Combobox","description":"","kind":"component","category":"inputs","status":"beta","props":{"items":{"type":"array","items":{"value":"string","label":"string","icon":"icon? (React: a node; Vue / Svelte: a component)","meta":"string?","disabled":"boolean?","keywords":"string[]?"},"description":"Options in order. Strings are accepted as value = label. keywords: other words that find the option (ISO codes, cities, abbreviations, former names); matched like the label, never shown. With none, the field is disabled."},"value":{"type":"string","model":true,"description":"Selected value, or null. The field shows its label."},"placeholder":{"type":"string","default":"Search"},"label":{"type":"string","description":"Visible label; otherwise pass aria-label."},"start":{"type":"node","description":"Before the text, inside the field (React node; Vue slot `start`, or text; Svelte snippet, or text): an icon that says what the field holds (a globe for a country), or something that shows the choice (the assignee's avatar, a status dot). Decorative unless it carries its own label; a press on it lands in the field."},"end":{"type":"node","description":"After the text, inside the field, before the caret (React node; Vue slot `end`, or text; Svelte snippet, or text): a bookmark star (a Toggle, variant ink), a status, a count. The field's padding follows it: the text stops 8px before it, and it keeps the size's padding from the edge (2px when it ends in a button, as the caret), or sits against the caret. A press on it lands in the field; a control inside it keeps its own press."},"emptyText":{"type":"string","default":"No results","description":"The row shown when nothing matches."},"allowCustomValue":{"type":"boolean","default":false,"description":"Free text: Enter with no option highlighted (nothing matches) keeps what was typed, trimmed, as the value; valueChange fires with that text and the list closes. The kept text is shown as an option of its own (checked, at the end of the list) until the caller adds it to items. For pickers that may create what they pick (a new label, a tag, an email address). Off: Enter with no match puts back the chosen label. Escape, Tab and a click outside never keep text either way."},"highlightMatch":{"type":"boolean","default":false,"description":"While the user types, each option's label dims to ink-2 and the part that matches the text stays in ink (Chrome's address suggestions, an editor's quick open): the match says why the option is listed. For long lists of similar names (files, URLs, people); a short list of distinct words does not need it."},"triggerLabel":{"type":"string","default":"Show options","description":"aria-label of the caret button."},"caret":{"type":"boolean","default":true,"description":"The caret button at the end. false leaves it out (a dense table cell, a field whose start icon already says it opens a list): the list opens by typing, a click in the field or ArrowDown, and the text keeps the size's padding at its end."},"size":{"type":"enum","values":["xs","sm","md","lg"],"default":"md","description":"The shared control's sizes (`lib/control.ts`), dimensions only: xs 24px, sm 28px, md 32px, lg 36px. Up to 28px the list's rows are 26px."},"variant":{"type":"enum","values":["outline","subtle","ghost"],"default":"outline","description":"The shared control's looks (`lib/control.ts`), at every size. outline: the form field (field colour, hairline). subtle: the inspector (inset grey, no edge). ghost: nothing until touched. Focused, open and invalid look the same in every variant."},"disabled":{"type":"boolean","default":false},"invalid":{"type":"boolean","default":false},"name":{"type":"string","description":"Form field name; the input carries it."},"placement":{"type":"string","default":"bottom-start","description":"Preferred side; flips when there is no room."}},"playground":{"name":"Playground","props":{"label":"Reviewer","placeholder":"Search people","emptyText":"No one in Northwind matches","size":"md","variant":"outline","disabled":false,"invalid":false,"items":[{"value":"maya","label":"Maya Chen","meta":"Owner"},{"value":"daniel","label":"Daniel Okafor","meta":"Admin"},{"value":"priya","label":"Priya Raman","meta":"Member"},{"value":"lucas","label":"Lucas Moreau","meta":"Member"},{"value":"sofia","label":"Sofia Alvarez","meta":"Viewer","disabled":true},{"value":"jonas","label":"Jonas Weber","meta":"Member"}]},"width":240},"exampleFiles":[{"file":"reviewer","title":"Assign a reviewer"},{"file":"branch-to-deploy","title":"Branch in a deploy bar"},{"file":"address-bar","title":"A browser's address bar, with a bookmark star"},{"file":"timezone","title":"Timezone, with UTC offsets"},{"file":"billing-country","title":"Billing country decides the tax"},{"file":"assignee-in-side-panel","title":"Assignee in an issue's side panel"},{"file":"country-by-code","title":"Country, found by its code or a city"},{"file":"new-label","title":"Label, or create a new one"},{"file":"go-to-file","title":"Go to file, the typed part marked"}],"worstCase":[{"name":"Long options","width":160,"props":{"aria-label":"Layout","items":[{"value":"a","label":"Grid"},{"value":"b","label":"Seasonal revenue performance across every regional store for the whole of last year"},{"value":"c","label":"supplier-contracts-renewal-schedule-and-pricing-history-export"},{"value":"d","label":"Z"}]}},{"name":"Many options","width":220,"props":{"label":"Currency","items":["US dollar","Euro","British pound","Japanese yen","Swiss franc","Canadian dollar","Mexican peso","Swedish krona","Australian dollar","Danish krone","Norwegian krone","Polish zloty","Czech koruna","Indian rupee","Korean won","Brazilian real","Turkish lira","Thai baht","Israeli shekel","South African rand"]}},{"name":"Long chosen label","width":160,"props":{"aria-label":"Report","value":"b","items":[{"value":"a","label":"Weekly"},{"value":"b","label":"Seasonal revenue performance across every regional store"}]}},{"name":"No options","width":220,"props":{"label":"Supplier","items":[]}},{"name":"Right-to-left options","width":220,"props":{"label":"المورد","placeholder":"ابحث","items":["ألبين للاستضافة","مجموعة كوبالت","Core Works","بيت فانتاج"]}},{"name":"Long start","width":200,"props":{"aria-label":"Owner","start":"Out of office until Dec 3","value":"maya","items":[{"value":"maya","label":"Maya Chen"},{"value":"aleksandra","label":"Aleksandra Wiśniewska-Kowalczyk"}]}},{"name":"Long free text","width":160,"props":{"aria-label":"Tag","allowCustomValue":true,"items":["bug","docs"]}},{"name":"Right-to-left, start, no caret","width":220,"props":{"label":"القناة","placeholder":"ابحث","start":"#","caret":false,"items":[{"value":"a","label":"النشر","keywords":["deploys"]},{"value":"b","label":"الفوترة","keywords":["billing"]},{"value":"c","label":"web-app"}]}}],"anatomy":[{"part":"root","element":"div"},{"part":"label","element":"label","optional":true},{"part":"control","element":"div","description":"The shared control (`lib/control.ts`), field kind: its sizes (xs 24 · sm 28 · md 32 · lg 36) and looks (outline, subtle, ghost) holding the input and the caret. A text field: the accent ring shows for every kind of focus and while the list is open. data-state=open|closed, data-focus, data-invalid, data-disabled from the engine."},{"part":"start","element":"span","optional":true,"description":"Before the text, inside the control: an icon (14px, ink-3), an avatar or a status that says what the field holds or shows what is chosen (the assignee's avatar, a globe for a country). As far from the edge as the text would be (the size's padding), or 2px when it begins with a button (the end part's rule, mirrored); the text starts 8px after it. Text in it stays on one line and is cut at 45% of the field, with a title while cut; elements never shrink. A press on it is a press in the field (focus, and the list opens as from a click in the field); a control inside it (a button, a link) keeps its own press. Not part of the field's name: a start that carries meaning says it in its own text."},{"part":"input","element":"input","description":"role=combobox; fills the control; aria-activedescendant follows the highlight. dir=auto: the text keeps its own direction, the alignment follows the page. 16px on coarse pointers. After a start part its text begins 8px after it; with no caret it keeps the size's padding at its end."},{"part":"end","element":"span","optional":true,"description":"After the text, inside the control, before the caret: a star, a status, a count (text ink-2, icons ink-3 and 14px). The text stops 8px before it; it keeps the size's padding from the end (2px when it ends in a button), none before the caret."},{"part":"trigger","element":"button","description":"The real Button (ghost, xs, square, muted), marked data-combobox=\"trigger\", with an aria-label. Not a tab stop (the engine sets tabindex=-1); a click toggles the list. Left out when caret is false.","optional":true},{"part":"indicator","element":"span","description":"The caret inside the trigger; flips while open over duration.move, instant from the keyboard (kbd-instant), as the select's.","optional":true},{"part":"positioner","element":"div","description":"Placed by the engine under the control; rendered in a portal. Exposes --transform-origin, --reference-width, --available-height"},{"part":"content","element":"div","description":"role=listbox; the shared popup surface (`lib/popup.ts`). The select's width: never narrower than the control (or 120px), then as wide as its longest option, up to 360px. sizes xs and sm: 26px rows."},{"part":"highlight","element":"span","description":"Shared gliding highlight layer (`glideLayer` of `lib/glide.ts`); glides under the pointer and the arrow keys alike"},{"part":"item","element":"div","repeat":true,"description":"role=option; data-highlighted, data-state=checked|unchecked, data-disabled. Only the options whose label or one of whose keywords contains the typed text (case-insensitive) are rendered. The shared option row (`lib/option.ts`)."},{"part":"item-icon","element":"span","optional":true,"description":"Leading icon of an option (14px, ink-3; aria-hidden): a file icon, a site's favicon. React: a node (a Phosphor icon with data-slot=\"icon\" weight=\"bold\", or a 14px <img>); Vue and Svelte: a component (drawn bold). An image is 14px with a 3px radius."},{"part":"item-text","element":"span","description":"Shown whole: wraps past the list's 360px cap, never cut. With highlightMatch and a label that contains the typed text: the label in ink-2, its match (item-match) in ink."},{"part":"item-match","element":"span","optional":true,"description":"highlightMatch: the first run of the label that matches the typed text (case-insensitive), in ink inside the label's ink-2. Colour only, never weight, so the label keeps its width as the user types. Absent when nothing is typed or the option was found by a keyword."},{"part":"item-meta","element":"span","optional":true,"description":"Trailing muted note"},{"part":"item-indicator","element":"span","description":"Check on the selected option; keeps its space on other rows"},{"part":"empty","element":"div","description":"Rendered by the engine only when nothing matches: one muted row the height of an option (emptyText)."}],"events":{"valueChange":"(value: string | null) when an option is chosen, or with the typed text when allowCustomValue keeps it","openChange":"(open: boolean)","inputValueChange":"(text: string) as the user types and when a choice writes its label"},"states":["hover","focus","open","highlighted","selected","disabled","invalid","empty"],"tokens":["color.field","color.inset","color.surface","color.hover","color.hover-2","color.ink","color.ink-2","color.ink-3","color.accent","color.accent-tint","color.red","color.red-tint","shadow.hairline","shadow.raised","radius.control","radius.chip","radius.card","text.2xs","text.xs","text.sm","text.md","duration.fast","duration.base","duration.popup","duration.move","duration.press","easing.out-strong","motion.popup-scale","motion.press-scale"],"a11y":{"role":"combobox + listbox","keyboard":["Typing opens the list and filters it; the first match is highlighted","ArrowDown / ArrowUp open the list, then move the highlight (wraps); Home / End jump to the first and last option while it is open","Enter chooses the highlighted option, closes the list and writes its label into the field","Enter with nothing highlighted (no match): with allowCustomValue, keeps the typed text as the value and closes the list; without it, puts back the chosen label and closes the list","Escape closes the list; a second Escape puts back the chosen label. Focus stays in the field","Tab closes the list and moves on; a click outside the open list puts back the chosen label"],"notes":["Give it a visible label or an aria-label; the caret button has its own aria-label and is not a tab stop.","Focus never leaves the field: options are reached through aria-activedescendant.","The list opens instantly when opened from the keyboard or by typing; the pointer gets the popup's scale-in. The highlight glides for the pointer and the arrow keys alike.","Every option is readable in full: the list grows to its longest option and wraps anything longer than its cap.","Keywords find an option without being read out: the option is announced by its label, so a keyword should be something the label stands for (DE for Germany, Tokyo for Asia/Tokyo).","The start part is not in the field's accessible name. A start that carries meaning (a status) says it in its own text (aria-label, title or visually hidden text); an icon that only decorates is aria-hidden.","With caret false the field is still announced as a combobox with a list (aria-expanded, aria-controls); ArrowDown and typing open it.","The field's text is one run, in ink: a native input cannot colour a range, and a display overlay (a host in ink, the path dimmer, as Chrome's address bar) is not worth its cost: it must copy the input's scroll, caret, selection, IME composition, font metrics and direction at every keystroke (and drifts by a subpixel at 125% scaling when it does not), and Chrome itself drops the emphasis as soon as the field is edited. A host can show the parts outside the field (in the start part, or in the options).","The match marking (highlightMatch) is colour only and is not announced: the option is read by its whole label."]},"motion":["popup: the shared popup surface (`lib/popup.ts`): opacity + scale from motion.popup-scale out of the control, along the block axis only (the list is as wide as the control, and its sides stay on the control's sides however wide it is), duration.popup, easing.out-strong; closes at duration.fast; instant when opened or closed from the keyboard or by typing","caret: rotate 180deg over duration.move, easing.out-strong; instant from the keyboard","highlight: one layer glides between options over duration.move, under the pointer and the arrow keys alike","rows: no entrance; the list changes on every keystroke. A pressed option darkens to color.hover-2 over duration.fast","control: fill over duration.fast, ring over duration.base; the caret button presses as a Button (motion.press-scale over duration.press)","start: no motion of its own; it changes with the value at once (an avatar swaps with the chosen person)","free text kept by Enter: instant, as every keyboard choice; the list closes without its exit"]}