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/select.md.

Select

Select provides a styled single-choice list when the product needs a consistent popup or richer option content. Use Combobox when users need to search or create values.

Fruit choice

No fruit selected yet.

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, Select component CSS, and one style pack.

@import "tailwindcss";
@import "@a3s-lab/ui/base.css";
@import "@a3s-lab/ui/components/select.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 Select script.

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

Using CDN or bundler imports? See the Installation page.

Add your select HTML

<div id="select-theme" class="select" data-placeholder="Theme">
  <button type="button" role="combobox" class="w-[180px]" id="select-theme-trigger" aria-label="Theme" aria-haspopup="listbox" aria-autocomplete="none" aria-expanded="false" aria-controls="select-theme-listbox">
    <span class="truncate">Theme</span>
    <svg 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="lucide lucide-chevron-down text-muted-foreground opacity-50 shrink-0"><path d="m6 9 6 6 6-6" /></svg>
  </button>
  <div id="select-theme-popover" data-popover aria-hidden="true">
    <div role="listbox" id="select-theme-listbox" aria-orientation="vertical" aria-labelledby="select-theme-trigger">
      <div role="option" data-value="light">Light</div>
      <div role="option" data-value="dark">Dark</div>
      <div role="option" data-value="system">System</div>
    </div>
  </div>
  <input type="hidden" name="theme" value="" />
</div>

HTML structure

<div class="select">

Select root. Add data-placeholder to show placeholder text when no value is selected. Supports data-close-on-select="true" for multiple select and data-format="object" for serialized object values.

<button type="button">
Select-only combobox trigger. Give it a stable accessible name with a connected <label>, aria-label, or aria-labelledby; placeholder text is a value hint, not a label. Use role="combobox", aria-haspopup="listbox", aria-autocomplete="none", aria-expanded, and aria-controls. The controller supplies stable option IDs for aria-activedescendant.
<div data-popover aria-hidden="true">

Popover content. Supports data-side and data-align through the shared Popover rules; the runtime flips and clamps the list to the visual viewport.

<div role="listbox">

Options container. Add aria-multiselectable="true" for multiple selection.

<div role="option" data-value="..." data-label="...">
Selectable option. data-value is submitted. data-label is optional and controls the selected display label and data-format="object" label; when omitted, A3S UI uses trimmed text content.
<hr role="separator"> Optional
Separator between groups or options.
<div role="group"> Optional
Option group. Use aria-labelledby to connect it to its heading.
<span role="heading"> Optional
Group heading.
<input type="hidden">
Submitted value. Empty value means no selection when the root has data-placeholder. Single select stores a string; multiple select stores a JSON array. With data-format="object", values are serialized as { value, label } objects.

JavaScript API

APITypeDescription
changeEventDispatched on selection changes with event.detail.value and event.detail.selected.
select.refresh()MethodRescans options after children change inside the existing role="listbox" element.

Examples

Groups

Live preview

Scrollable

A select with many items that scrolls.

Live preview

Disabled control

Live preview

Disabled option

Disabled options stay visible for context but are skipped by pointer, arrow-key, Home, End, and typeahead navigation.

Live preview

Invalid

Live preview

Please select a valid fruit.

RTL

Live preview

Accessibility

Give every trigger a stable accessible name with a connected label, aria-label, or aria-labelledby; the placeholder and selected value do not replace the field label. Focus remains on the select-only combobox trigger while aria-activedescendant identifies the active option. Arrow keys move through enabled options, Home and End reach the first and last enabled option, printable text performs accent-insensitive typeahead, Enter or Space commits, and Escape closes without changing the value and restores trigger focus.