Form input components: text fields, selects, textareas, and search inputs.
Designed to work seamlessly with Phoenix.HTML.Form and Ecto.Changeset.
Features
- Consistent sizing and border tokens
- Error state driven by
Phoenix.HTML.Formfield errors - Label, hint, and error message composable slots
- Prefix/suffix icon support
- Native integration with
phx-changeandphx-debounce
Examples
<%!-- Basic usage with a changeset form --%>
<.input field={@form[:email]} type="email" label="Email address" />
<%!-- With hint text --%>
<.input field={@form[:username]} label="Username" hint="Letters and numbers only" />
<%!-- Password with show/hide toggle (uses the Toggle hook) --%>
<.input field={@form[:password]} type="password" label="Password" />
<%!-- Search input --%>
<.input type="search" name="q" value={@query} placeholder="Search…" phx-change="search" phx-debounce="200" />
<%!-- With prefix icon --%>
<.input field={@form[:amount]} type="number" label="Amount">
<:prefix>฿</:prefix>
</.input>
<%!-- Standalone (no form) --%>
<.input type="text" name="tag" id="tag-input" value="" placeholder="Add tag…" />
Summary
Functions
Renders a form input with label, error handling, and optional prefix/suffix.
Select dropdown — wraps <select> with consistent styling.
Functions
Renders a form input with label, error handling, and optional prefix/suffix.
Attributes
id(:any) - Defaults tonil.name(:any) - Defaults tonil.value(:any) - Defaults tonil.type(:string) - Defaults to"text". Must be one of"text","email","password","search","number","tel","url", or"textarea".label(:string) - Defaults tonil.hint(:string) - Defaults tonil.placeholder(:string) - Defaults tonil.required(:boolean) - Defaults tofalse.disabled(:boolean) - Defaults tofalse.class(:string) - Defaults tonil.field(Phoenix.HTML.FormField) - A %Phoenix.HTML.FormField{} — binds id, name, value, errors automatically.- Global attributes are accepted. Supports all globals plus:
["phx-change", "phx-blur", "phx-focus", "phx-debounce", "autocomplete", "min", "max", "step", "pattern", "readonly"].
Slots
prefix- Content rendered inside the input on the left (icon or text like '฿', '@').suffix- Content rendered inside the input on the right (clear button, unit label).inner_block
Select dropdown — wraps <select> with consistent styling.
Example
<.select field={@form[:region]} label="Region" options={["Bangkok", "Singapore", "Tokyo"]} />
<.select name="status" label="Status" options={[{"Active", "active"}, {"Inactive", "inactive"}]} value={@filter} />Attributes
id(:any) - Defaults tonil.name(:any) - Defaults tonil.value(:any) - Defaults tonil.label(:string) - Defaults tonil.hint(:string) - Defaults tonil.options(:list) (required)prompt(:string) - Placeholder option (empty value). Defaults tonil.field(Phoenix.HTML.FormField) - Binds from a Phoenix form field.class(:string) - Defaults tonil.- Global attributes are accepted. Supports all globals plus:
["phx-change", "phx-blur", "disabled", "required"].