Combobox

stable 4.8 kB
<hk-combobox>

A select that also accepts what you typed. Suggestions match on any part of the text, and anything with no match becomes a new value on Enter.

#autocomplete#search
In the package npm i hellskitchen-ui Import hk-combobox and use it directly.

Live demo

Running in this page — interact with it.

Inputs

NameTypeDefaultDescription
valuestring[][]Chosen values, custom entries included. Two-way bindable.
optionsstring[][]Suggestions offered while typing.
allowCustombooleantrueEnter commits free text that matches nothing.
maxItemsnumber | nullnullCaps how many values can be chosen.
loadingbooleanfalseShows the async state while suggestions are fetched.
placeholderstring'Add a label…'Shown in the empty text field.

Outputs

  • valueChangeEventEmitter<string[]>

    Emits on add and on remove.

  • searchEventEmitter<string>

    Query debounced by 250ms, for server-side suggestions.

Keyboard

  • Enter Commits the highlighted suggestion, or the typed text
  • Backspace On an empty field, removes the last chip
  • ↑ / ↓ Moves through suggestions
  • Escape Dismisses the suggestion list

Theming

Component tokens, each falling back to a global one:

PropertyDefaultControls
--hk-combobox-chip-bgrgb(220 38 38 / 0.10)Chip fill for a chosen value.
--hk-combobox-chip-text#b91c1cChip label colour.

Accessibility

  • Backspace on an empty field peels the last chip — the behaviour every tag input is expected to have.
  • Each chip carries its own labelled remove button, so removal never depends on the keyboard shortcut.
  • The suggestion list is an aria-expanded combobox popup, announced as it filters.

More in Forms