Combobox — searchable select input.
Filtering happens server-side via phx-change on the search input.
Open/close state is managed by a lightweight JS hook (AvenUICombobox).
Works as a drop-in replacement for a plain <select> in any LiveView form.
Examples
<%!-- Basic — static options --%>
<.combobox
id="country"
name="country"
placeholder="Search countries…"
options={[
%{value: "th", label: "Thailand"},
%{value: "sg", label: "Singapore"},
%{value: "jp", label: "Japan"},
]}
selected={@selected_country}
/>
<%!-- With live search — filter on server --%>
<.combobox
id="user-search"
name="user_id"
placeholder="Search users…"
options={@filtered_users}
selected={@selected_user}
on_search="search_users"
/>
<%!-- With Phoenix form field --%>
<.combobox
id="role"
field={@form[:role]}
placeholder="Select role…"
options={[
%{value: "admin", label: "Admin"},
%{value: "editor", label: "Editor"},
%{value: "viewer", label: "Viewer"},
]}
/>Handle server-side search
def handle_event("search_users", %{"query" => query}, socket) do
users = Accounts.search_users(query)
{:noreply, assign(socket, :filtered_users, users)}
endOption format
Options can be a list of maps:
%{value: "th", label: "Thailand"}
%{value: "th", label: "Thailand", disabled: true}Or a list of {label, value} tuples:
[{"Thailand", "th"}, {"Singapore", "sg"}]
Summary
Functions
Searchable combobox — drop-in replacement for a select field.
Functions
Searchable combobox — drop-in replacement for a select field.
Attributes
id(:string) (required)name(:string) - Defaults tonil.field(Phoenix.HTML.FormField) - Defaults tonil.options(:list) - Defaults to[].selected(:any) - Defaults tonil.placeholder(:string) - Defaults to"Search…".on_search(:string) - phx-change event name for server-side filtering. Defaults tonil.disabled(:boolean) - Defaults tofalse.required(:boolean) - Defaults tofalse.label(:string) - Defaults tonil.hint(:string) - Defaults tonil.error(:string) - Defaults tonil.class(:string) - Defaults tonil.- Global attributes are accepted.