# `LedgerUI.Components.Select`
[🔗](https://github.com/devaction-labs/ledger_ui/blob/v0.2.0/lib/ledger_ui/components/select.ex#L212)

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.

# `select`

## Attributes

* `id` (`:string`) - Defaults to `nil`.
* `name` (`:string`) - Defaults to `nil`.
* `value` (`:any`) - Defaults to `nil`.
* `field` (`Phoenix.HTML.FormField`) - Defaults to `nil`.
* `label` (`:string`) - Defaults to `nil`.
* `label_hint` (`:string`) - Defaults to `nil`.
* `help` (`:string`) - Defaults to `nil`.
* `errors` (`:list`) - Defaults to `[]`.
* `options` (`:list`) - Defaults to `[]`.
* `prompt` (`:string`) - Defaults to `nil`.
* `placeholder` (`:string`) - Defaults to `nil`.
* `multiple` (`:boolean`) - Defaults to `false`.
* `disabled` (`:boolean`) - Defaults to `false`.
* `native` (`:boolean`) - Defaults to `false`.
* `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 to `false`.
* `icon` (`:string`) - An icon before the text. Defaults to `nil`.
* `removable` (`:boolean`) - Defaults to `false`.
* `clearable` (`:boolean`) - Defaults to `false`.
* `clear_label` (`:string`) - Defaults to `"Clear"`.
* `remove_label` (`:string`) - Defaults to `"Remove"`.
* `create` (`:boolean`) - Defaults to `false`.
* `create_label` (`:string`) - Defaults to `"Add"`.
* `create_hint` (`:string`) - Defaults to `nil`.
* `persist` (`:boolean`) - Defaults to `true`.
* `restore_on_backspace` (`:boolean`) - Defaults to `false`.
* `max` (`:integer`) - Defaults to `nil`.
* `overflow` (`:string`) - Defaults to `"count"`. Must be one of `"count"`, or `"wrap"`.
* `footer` (`:boolean`) - Defaults to `false`.
* `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 to `nil`.
* `panel_class` (`:any`) - Defaults to `nil`.
* `on_search` (`:string`) - Defaults to `nil`.
* `debounce` (`:integer`) - Defaults to `300`.
* `target` (`:any`) - Defaults to `nil`.
* `on_load_more` (`:string`) - Defaults to `nil`.
* `has_more` (`:boolean`) - Defaults to `false`.
* `loading_label` (`:string`) - Defaults to `"Loading…"`.
* `open` (`:boolean`) - Renders the list open (static previews). Defaults to `false`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted. Supports all globals plus: `["form", "autocomplete", "required"]`.
## Slots

* `below`
* `item`
* `label_aside`
* `option`
* `suffix`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
