Select inputs.
Ports the Pines select as select_menu/1 — a
custom listbox with full keyboard support — alongside select/1, a styled native
<select>.
<.select name="country" label="Country" options={[{"US", "us"}, {"Canada", "ca"}]} />
<.select_menu name="country" options={[{"US", "us"}]} searchable />Which one to use
Prefer select/1. A native select is accessible for free, works on every device, and
renders its dropdown outside the page so it is never clipped by an ancestor's
overflow: hidden. Reach for select_menu/1 only when you need something the native
control cannot do — search, rich option markup, or multi-select chips.
Summary
Forms
Renders a styled native <select>.
Renders a custom listbox with keyboard navigation and optional search.
Forms
Renders a styled native <select>.
Examples
<.select name="country" label="Country" prompt="Choose…"
options={[{"United States", "us"}, {"Canada", "ca"}]} value={@country} />
<.select name="city" options={[
{"North America", [{"Toronto", "yyz"}, {"New York", "nyc"}]},
{"Europe", [{"Paris", "cdg"}]}
]} />Attributes
id(:string) - Defaults tonil.name(:string) (required)options(:list) -{label, value}tuples, or{group_label, [{label, value}]}to render<optgroup>s. Bare strings and atoms are accepted and used as both label and value.Defaults to
[].value(:any) - Defaults tonil.prompt(:string) - A leading, valueless option. Defaults tonil.label(:string) - Defaults tonil.hint(:string) - Defaults tonil.error(:string) - Defaults tonil.disabled(:boolean) - Defaults tofalse.required(:boolean) - Defaults tofalse.multiple(:boolean) - Defaults tofalse.class(:string) - Defaults tonil.container_class(:string) - Defaults tonil.Global attributes are accepted.