Combobox
Usage
Include CSS
Import Tailwind and one full A3S UI style bundle.
Or import only the base CSS, Combobox component CSS, and one style pack.
Using CDN or bundler imports? See the Installation page.
Include JavaScript
Copy or serve the full A3S UI JavaScript bundle.
Or copy or serve the A3S UI runtime and Combobox script.
Using CDN or bundler imports? See the Installation page.
Add your combobox HTML
Combobox is input-first. The visible input filters the list; the hidden input stores the submitted value.
HTML structure
<div class="combobox">Root element. Add
data-auto-highlight="true"to make the first visible option active when the list opens or filters. Adddata-format="object"to serialize selected values as objects. Adddata-filter="manual"when your app owns filtering.<input type="text" role="combobox">- The editable control. It can be a direct child, inside
.input-group, or insidedata-popoverfor popup mode. <button aria-haspopup="listbox">Optional- Opens the list from an input group or popup trigger. In popup mode, include a child with
data-valueand optionaldata-placeholderto display the selected value. <button data-clear>Optional- Clears the current selection. Put the clear icon inside the button.
<svg class="combobox-trigger-icon">Optional- Decorative trailing icon for input-style comboboxes. Replace the SVG to customize the icon.
<div data-popover>- The suggestions popup. Use
data-sideanddata-alignlike Popover; the shared runtime flips and clamps the list to the visual viewport. <div role="listbox">- The suggestions list. Add
aria-multiselectable="true"in multiple mode. The component uses that attribute to render selected chips around the input. <div role="option" data-value="...">- Selectable option. Options can contain custom HTML; use
data-labelwhen the input should display different text than the rendered content. <input type="hidden">- Submitted value. Single mode stores a string; multiple mode stores a JSON array. With
data-format="object", selected values are stored as objects.
JavaScript API
Examples
Multiple
Clear button
Groups
Custom items
Invalid
Select a framework to continue.
Disabled
Auto highlight
Auto highlight makes the first visible option active when the list opens or filters, so pressing Enter can select it without arrowing first.