Skip to content

Dropdown Typeahead

<dsx-dropdown-typeahead> — Dropdown Typeahead

Section titled “<dsx-dropdown-typeahead> — Dropdown Typeahead”

Searchable dropdown control that supports both single-select and multi-select flows.

Live Preview
import '@bnotk/dsx/components/dropdown-typeahead.js';
<dsx-dropdown-typeahead id="city-picker" placeholder="Choose a city"></dsx-dropdown-typeahead>
<script type="module">
document.getElementById('city-picker').options = [
{ value: 'berlin', label: 'Berlin' },
{ value: 'hamburg', label: 'Hamburg' }
];
</script>

Option contract consumed by the options property.

FieldTypeDescription
valuestringSubmitted/stored value.
labelstringVisible option label used for filtering and display.
disabledbooleanOptional flag that blocks selection.

Composite control with selection tokens, optional search input, clear button, and dropdown list.

PropertyTypeDefaultDescription
optionsDsxOption[][]Available options rendered in the dropdown.
valuestring[][]Selected values. Even single-select mode stores the selection internally as an array.
multiplebooleanfalseEnables checkbox-style multi-selection and removable tokens.
searchablebooleantrueShows a live search input while the dropdown is open.
placeholderstringPlaceholder text shown when nothing is selected.
disabledbooleanfalseDisables open/close interactions and applies disabled styling.

None.

EventDetailDescription
dsx-change{ value: string | string[] }Bubbles/composed after selection, deselection, token removal, or clear.
dsx-search{ query: string }Bubbles/composed whenever the search input value changes.

None.

This element does not expose shadow parts.

  • Outside clicks are detected with a document mousedown listener registered after opening.
  • ArrowDown and ArrowUp move the highlight; Enter selects the highlighted option; Escape closes and clears the query.
  • In single-select mode the control closes immediately after a selection and the event detail contains a single string instead of an array.
  • Options are filtered case-insensitively against label.includes(query).
  • Multiple mode shows token chips inside the control plus a checkbox in each dropdown option.
  • Selected options gain the selected class; keyboard-highlighted options gain the highlighted class; disabled options ignore selection.
  • The clear button only appears when at least one value is selected.
  • The control uses inset box-shadow borders and switches to a 2px focus ring with --ds2-color-focus when open.
  • Dropdown is absolutely positioned below the control with a 15rem max height and internal scrolling.
  • Tokens use small grey pills; the dropdown uses white surface, grey border, and highlight colors from the token set.