Autocomplete
Request matching options from the server as a user types.
- Atlas
- Beacon
- Cobalt
- Drift
- Iris
- Lumen
- Studio North
HTML
<div class="rl-scope" data-rl-scope>
<div class="rl-field">
<label class="rl-label" for="demo-autocomplete">Workspace</label>
<div class="rl-combo" data-rl-combo data-rl-combo-remote>
<input class="rl-input" id="demo-autocomplete" name="q" type="text" role="combobox"
aria-expanded="false" aria-controls="demo-autocomplete-options" aria-autocomplete="list"
autocomplete="off" placeholder="Find a workspace…"
hx-get="/demo/catalog/autocomplete" hx-trigger="input changed delay:180ms, relay:query"
hx-target="next [role=listbox]" hx-swap="innerHTML" hx-sync="this:replace">
<ul class="rl-listbox rl-combo-list" id="demo-autocomplete-options" role="listbox" aria-label="Workspaces" hidden>
<li class="rl-option" id="demo-autocomplete-atlas" role="option" aria-selected="false">Atlas</li>
<li class="rl-option" id="demo-autocomplete-beacon" role="option" aria-selected="false">Beacon</li>
<li class="rl-option" id="demo-autocomplete-cobalt" role="option" aria-selected="false">Cobalt</li>
<li class="rl-option" id="demo-autocomplete-drift" role="option" aria-selected="false">Drift</li>
<li class="rl-option" id="demo-autocomplete-iris" role="option" aria-selected="false">Iris</li>
<li class="rl-option" id="demo-autocomplete-lumen" role="option" aria-selected="false">Lumen</li>
<li class="rl-option" id="demo-autocomplete-studio-north" role="option" aria-selected="false">Studio North</li>
</ul>
<span class="rl-description" data-rl-combo-status role="status"></span>
</div>
</div>
</div>HTTP exchange
Use the preview to see the request and the HTML your server returns.HTMX replaces the options with a server-rendered fragment. Use the arrow keys and Enter to select a result. A search without matches leaves the empty message visible.
Use in your app
Copy these tags into your page head once. Serve the files at the paths shown, then add the example’s template to your page.
Page assets
<link rel="stylesheet" href="/mero.css">
<script defer src="/vendor/htmx.min.js"></script>
<script defer src="/mero.js"></script>Point the HTMX attributes at your own HTML endpoints. Use the live preview’s HTTP exchange to inspect the request and response.
Download library and examples ↓