Components ds-combobox
Combobox
Text input with a popup listbox of suggestions. Focus stays in the input while the arrow keys move through the suggestions, and the page decides what to suggest from each ds-input.
Live playground
Type to filter, or press ArrowDown to open the list. Enter or a click chooses a suggestion; Escape closes the list and keeps the text.
- ds-input
- empty
- aria-activedescendant
- none
- ds-select
- none yet
Interactive props
Usage example
<label for="produce-input">Fruit or vegetable</label>
<ds-combobox @ds-input=${(e) => this.query = e.detail.value}>
<input slot="input" id="produce-input" autocomplete="off" />
<ds-listbox aria-label="Suggestions">
${matches.map((item) => html`<ds-option>${item}</ds-option>`)}
</ds-listbox>
</ds-combobox>
Keyboard
| Key | Result |
|---|---|
| Arrow Down / Up | Opens the list on the first or last suggestion, then moves through it. |
| Alt + Arrow Down / Up | Opens the list without moving, or closes it. |
| Enter | Chooses the active suggestion, or closes the list when none is active. |
| Escape | Closes the list and keeps the text. |
| Tab | Closes the list and moves on without choosing. |
API Reference
| Member | Kind | Description |
|---|---|---|
| open | property | Whether the list is open. It shows only while it has options. |
| ds-input | event | Every edit of the text, and the label of a chosen option. Detail: {value}. Not debounced. |
| ds-select | event | Dispatched by the slotted listbox. Detail: {option, value}. |
| input | slot | The text input, which becomes the combobox element. |
| (default) | slot | The ds-listbox of suggestions. |
| --ds-combobox-popup-max-height | css | Height beyond which the list scrolls. Defaults to 16rem. |