Combobox
moleculesFloats a listbox of suggestions under a field you render; owns placement, combobox ARIA and the keys while you own when it opens and what it lists.
Assignee picker
options filtered from the query, bind:open and bind:index, an option snippet with Avatar, empty text and onselect.
Mentions in a textarea
anchor="caret" pins the listbox under the cursor; findTrigger detects the @ token and applyTrigger replaces it. Type @ to try.
States
an empty snippet, a disabled field, loop={false} with homeEnd, selectOn={["Enter"]} so Tab leaves the field, and placement="top-start".
Props
| Prop | Type | Default | Description |
|---|---|---|---|
options required | T[] | — | |
open bindable | boolean | false | Whether the listbox shows. The kit only ever sets it to `false`. |
index bindable | number | 0 | Highlighted option. |
label required | string | — | Accessible name of the listbox. |
el | FieldEl | null | null | The wrapped field; defaults to the first `input`/`textarea` in `children`. |
anchor | 'field' | 'caret' | 'field' | Float under the field's edge, or under the text caret. |
placement | Placement | 'bottom-start' | |
gap | number | 4 | |
loop | boolean | true | Arrow keys wrap at the ends. |
homeEnd | boolean | false | Home/End jump the highlight instead of moving the caret. |
selectOn | readonly ('Enter' | 'Tab')[] | ['Enter', 'Tab'] | Keys that pick the highlighted option. |
closeOnBlur | boolean | true | Close when focus leaves the field and the listbox. |
fieldRole | 'auto' | 'combobox' | 'none' | 'auto' | `role="combobox"` on the field: `auto` applies it to an `input` only, since ARIA in HTML forbids it on a `textarea`. |
getKey | (option: T, index: number) => string | number | — | |
getLabel | (option: T) => string | (o) => String(o) | Default row text when no `option` snippet is given. |
onselect | (option: T, index: number) => void | — | |
onclose | (reason: CloseReason) => void | — | |
option | Snippet<[T, { active: boolean; index: number }]> | — | |
empty | string | Snippet | — | Shown instead of rows when `options` is empty; without it the listbox hides. |
sound | boolean | true | Play UI sounds when enabled globally; false silences this instance. |
children required | Snippet | — | |
class | string | '' | |
style | string | '' | |
panelClass | string | '' | |
panelStyle | string | '' |