## Usage
This component ships a `combobox()` macro for Jinja and Nunjucks.
```html
```
Combobox is input-first. The visible input filters the list; the hidden input stores the submitted value.
```html
Next.js
SvelteKit
Nuxt.js
Remix
Astro
```
### 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.
<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
| API | Type | Description |
| --- | --- | --- |
| `change` | Event | Dispatched on selection changes with `event.detail.value` and `event.detail.selected`. |
| `combobox.setValue(value)` | Method | Sets the selected value from a plain value or `{ value, label }` object. |
| `combobox.clear()` | Method | Clears the selected value. |
| `combobox.refresh()` | Method | Rescans options after children change inside the existing `role="listbox"` element. |
## Examples
### Multiple
Next.js
SvelteKit
Nuxt.js
Remix
Astro
### Clear button
Next.js
SvelteKit
Nuxt.js
Remix
Astro
### Groups
Americas
(GMT-5) New York
(GMT-8) Los Angeles
(GMT-6) Chicago
(GMT-5) Toronto
(GMT-8) Vancouver
(GMT-3) São Paulo
Europe
(GMT+0) London
(GMT+1) Paris
(GMT+1) Berlin
(GMT+1) Rome
(GMT+1) Madrid
(GMT+1) Amsterdam
Asia/Pacific
(GMT+9) Tokyo
(GMT+8) Shanghai
(GMT+8) Singapore
(GMT+4) Dubai
(GMT+11) Sydney
(GMT+9) Seoul
### Custom items
ArgentinaSouth America
AustraliaOceania
JapanAsia
### Invalid
Next.js
SvelteKit
Nuxt.js
Remix
Astro
Select a framework to continue.
### Disabled
Next.js
### 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.