Select

stable 4.2 kB
<hk-select>

Single or multi select with typeahead filtering. The trigger is a combobox and the panel a listbox, with the active option tracked by aria-activedescendant.

#dropdown#picker
In the package npm i hellskitchen-ui Import hk-select and use it directly.

Live demo

Running in this page — interact with it.

Inputs

NameTypeDefaultDescription
valueunknown | unknown[]nullSelected value, or array when [multiple]. Two-way bindable.
optionsHkSelectChoice[] | string[][]Choices ({ label, value }). Plain strings are accepted as shorthand.
multiplebooleanfalseAllows more than one selection; the trigger lists every chosen label.
filterablebooleanfalseAdds the typeahead box to the panel.
placeholderstring'Select'Shown when nothing is chosen.
disabledbooleanfalseBlocks opening the panel.

Outputs

  • valueChangeEventEmitter<unknown>

    Emits on selection.

  • opened / closedEventEmitter<void>

    Panel lifecycle, for lazy option loading.

Keyboard

  • Space / Enter Opens the panel, or picks the active option
  • ↑ / ↓ Moves the active option
  • Home / End First / last option
  • Escape Closes without changing the value
  • Type a letter Jumps to the next option starting with it

Theming

Component tokens, each falling back to a global one:

PropertyDefaultControls
--hk-select-panel-bg#ffffffTrigger and dropdown background.
--hk-select-option-hover#f1f5f9Hovered and active option wash.
--hk-select-max-height11remPanel height before it scrolls.

Accessibility

  • Implements the listbox pattern: the trigger is a combobox, the panel a listbox, and aria-activedescendant tracks the active option without moving DOM focus.
  • Selected state is exposed through aria-selected, never through colour alone.

More in Forms