{% extends "base.html" %} {% block title %}Autocomplete (Combobox) - Design System Wiki{% endblock %} {% block content %}
Asynchronous search dropdown inputs driven by HTMX requests with fully integrated keyboard navigation, focus overlays, selection, and hidden inputs for form validation.
To query the MongoDB database on the server, you must sign in to an active session first.
Log in to query database
The global script combobox.js runs automatically on page load and hooks onto the class names listed below. Ensure your markup uses these selectors to integrate keyboard selection and local/remote filtering:
| Selector / Class | Type | Behavior & Purpose |
|---|---|---|
| .autocomplete-combobox | Class | Wraps all input elements, hidden inputs, and search result list containers. |
| .combobox-value | Class |
Applied to the <input type="hidden"> element that holds the final selection key (e.g. database ID) for form validation and submission.
|
| .combobox-input | Class |
Applied to the visible <input type="text"> element. Captures typing, trigger clicks, and keyboard arrow navigation events.
|
| .combobox-results | Class |
The overlay list container. Starts with the class hidden. Toggled open on focus, click, or when query results return.
|
| .combobox-item | Class |
Applied to option elements. Must contain tabindex="0" (for keyboard focus), data-id="..." (database value), and data-name="..." (display value).
|
You can customize the visual appearance of the options list .combobox-results, option heights, text alignment, input styles, borders, icons, and colors. The functional classes (like .combobox-input, .combobox-value, .combobox-item) must remain intact, and each item must include the data-id, data-name, and tabindex="0" attributes so they participate in keyboard selection cycling and updates.