{% extends "base.html" %} {% import "components/macros.html" as ui %} {% block title %}Autocomplete (Combobox) - Design System Wiki{% endblock %} {% block content %}
{% include "docs/sidebar.html" %}
Forms & Inputs

Autocomplete (Combobox)

Asynchronous search dropdown inputs driven by HTMX requests with fully integrated keyboard navigation, focus overlays, selection, and hidden inputs for form validation.

Autocomplete Showcase & Integration

Client-Side Filtering
Server-Side HTMX Search {% if authenticated %} {{ ui::search_combobox(name="assignee_id", label="Live MongoDB Query", placeholder="Query developers database...", search_url="/developers/search", input_id="wiki-db-search", value_id="wiki-db-value") }} {% else %}
Authentication Required

To query the MongoDB database on the server, you must sign in to an active session first.

Log in to query database
{% endif %}

How the Global Combobox JS Works

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).
💡 What is customizable?

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.

{% endblock %}