Select: the styled native <select> (native) and a searchable listbox driven by the
LedgerUI.Select hook (priv/static/ledger_ui/hooks/select.js).
<.select native label="Type" options={~w(Wedding Birthday Other)} />
<.select field={@form[:plan]} options={["Pro", "Scale", "Starter"]} />
<.select field={@form[:states]} options={@states} multiple removable clearable />
<.select field={@form[:author]} options={@authors} on_search="search_authors" target={@myself}>
<:option :let={author}>{author.label} · {author.data.job}</:option>
</.select>Options are strings, {label, value} tuples, maps or {group, options} (see
LedgerUI.Components.Select.Options).
The listbox submits through a hidden <select> named like the field (name[] when
multiple) and fires a bubbling input event when the choice changes, so a surrounding
phx-change runs. Opening, closing, keyboard and filtering never leave the browser; a
value sent by the server wins over the one in the browser.
on_search pushes %{"id" => id, "query" => text} (after debounce ms) and
on_load_more pushes %{"id" => id, "query" => text, "offset" => n} to target or the
LiveView.
Summary
Functions
Attributes
id(:string) - Defaults tonil.name(:string) - Defaults tonil.value(:any) - Defaults tonil.field(Phoenix.HTML.FormField) - Defaults tonil.label(:string) - Defaults tonil.label_hint(:string) - Defaults tonil.help(:string) - Defaults tonil.errors(:list) - Defaults to[].options(:list) - Defaults to[].prompt(:string) - Defaults tonil.placeholder(:string) - Defaults tonil.multiple(:boolean) - Defaults tofalse.disabled(:boolean) - Defaults tofalse.native(:boolean) - Defaults tofalse.variant(:string) - Defaults to"outline". Must be one of"outline", or"filled".size(:string) - Defaults to"md". Must be one of"sm","md", or"lg".shape(:string) - Defaults to"rounded". Must be one of"rounded", or"pill".inline(:boolean) - Defaults tofalse.icon(:string) - An icon before the text. Defaults tonil.removable(:boolean) - Defaults tofalse.clearable(:boolean) - Defaults tofalse.clear_label(:string) - Defaults to"Clear".remove_label(:string) - Defaults to"Remove".create(:boolean) - Defaults tofalse.create_label(:string) - Defaults to"Add".create_hint(:string) - Defaults tonil.persist(:boolean) - Defaults totrue.restore_on_backspace(:boolean) - Defaults tofalse.max(:integer) - Defaults tonil.overflow(:string) - Defaults to"count". Must be one of"count", or"wrap".footer(:boolean) - Defaults tofalse.footer_count(:string) - Defaults to"%{count} of %{total}".footer_hint(:string) - Defaults to"Esc to close".more_label(:string) - Defaults to"more".no_results(:string) - Defaults to"No results found".search(:string) - Defaults to"control". Must be one of"control","panel", or"none".search_placeholder(:string) - Defaults to"Search…".panel_min_width(:string) - Defaults tonil.panel_class(:any) - Defaults tonil.on_search(:string) - Defaults tonil.debounce(:integer) - Defaults to300.target(:any) - Defaults tonil.on_load_more(:string) - Defaults tonil.has_more(:boolean) - Defaults tofalse.loading_label(:string) - Defaults to"Loading…".open(:boolean) - Renders the list open (static previews). Defaults tofalse.class(:any) - Defaults tonil.- Global attributes are accepted. Supports all globals plus:
["form", "autocomplete", "required"].
Slots
belowitemlabel_asideoptionsuffix