For AI agents: the complete documentation index is available at https://a3s-lab.github.io/UI/en/llms.txt, the full documentation bundle is available at https://a3s-lab.github.io/UI/en/llms-full.txt, and this page is available as Markdown at https://a3s-lab.github.io/UI/en/components/combobox.md.

Combobox

Live previewHTML · CSS · JavaScript

Usage

Include CSS

Import Tailwind and one full A3S UI style bundle.

@import "tailwindcss";
@import "@a3s-lab/ui/a3s.css";

Or import only the base CSS, Combobox component CSS, and one style pack.

@import "tailwindcss";
@import "@a3s-lab/ui/base.css";
@import "@a3s-lab/ui/components/combobox.css";
@import "@a3s-lab/ui/styles/a3s.css";

Using CDN or bundler imports? See the Installation page.

Include JavaScript

Copy or serve the full A3S UI JavaScript bundle.

<script src="/assets/js/all.min.js" defer></script>

Or copy or serve the A3S UI runtime and Combobox script.

<script src="/assets/js/runtime.min.js" defer></script>
<script src="/assets/js/combobox.min.js" defer></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.

<div id="framework-combobox" class="combobox w-[240px]">
  <input type="text" role="combobox" placeholder="Select a framework" aria-label="Framework" autocomplete="off" autocorrect="off" spellcheck="false" aria-autocomplete="list" aria-expanded="false" aria-controls="framework-combobox-listbox" /><svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="combobox-trigger-icon"><path d="m6 9 6 6 6-6" /></svg>
  <div id="framework-combobox-popover" data-popover aria-hidden="true">
    <div role="listbox" id="framework-combobox-listbox" aria-orientation="vertical" data-empty="No items found.">
      <div role="option" data-value="Next.js">Next.js</div>
      <div role="option" data-value="SvelteKit">SvelteKit</div>
      <div role="option" data-value="Nuxt.js">Nuxt.js</div>
      <div role="option" data-value="Remix">Remix</div>
      <div role="option" data-value="Astro">Astro</div>
    </div>
  </div>
  <input type="hidden" name="framework" value="" />
</div>

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. Add data-format="object" to serialize selected values as objects. Add data-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 inside data-popover for 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-value and optional data-placeholder to 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-side and data-align like 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-label when 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

APITypeDescription
changeEventDispatched on selection changes with event.detail.value and event.detail.selected.
combobox.setValue(value)MethodSets the selected value from a plain value or { value, label } object.
combobox.clear()MethodClears the selected value.
combobox.refresh()MethodRescans options after children change inside the existing role="listbox" element.

Examples

Multiple

Live previewHTML · CSS · JavaScript

Clear button

Live previewHTML · CSS · JavaScript

Groups

Live previewHTML · CSS · JavaScript

Custom items

Live previewHTML · CSS · JavaScript

Invalid

Live previewHTML · CSS · JavaScript

Select a framework to continue.

Disabled

Live previewHTML · CSS · JavaScript

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.

Live previewHTML · CSS · JavaScript
Live previewHTML · CSS · JavaScript

Input group

Live previewHTML · CSS · JavaScript

RTL

Live previewHTML · CSS · JavaScript