Single-line text inputs.
A port of the Pines text input, extended with the label, hint, error, prefix/suffix and icon affordances a real form needs.
<.text_input name="email" type="email" label="Email" placeholder="you@example.com" />
Summary
Forms
Renders a labelled text input.
Forms
Renders a labelled text input.
Examples
<.text_input name="email" type="email" label="Email address"
placeholder="you@example.com" required />
<.text_input name="price" type="number" label="Price" prefix="$" suffix="USD" />
<.text_input name="q" placeholder="Search…" phx-change="search" phx-debounce="300">
<:icon><Heroicons.magnifying_glass class="h-4 w-4" /></:icon>
</.text_input>Accessibility
Hint and error text are wired to the input through aria-describedby, and an error also
sets aria-invalid and is announced via role="alert".
Attributes
id(:string) - Defaults tonil.name(:string) (required)type(:string) - Defaults to"text". Must be one of"text","email","password","search","tel","url","number","date","datetime-local","month","time","week", or"color".value(:string) - Defaults tonil.label(:string) - Defaults tonil.placeholder(:string) - Defaults tonil.hint(:string) - Helper text beneath the field. Defaults tonil.error(:string) - Validation message. Setsaria-invalid. Defaults tonil.prefix(:string) - Static text inside the field, before the value. Defaults tonil.suffix(:string) - Static text inside the field, after the value. Defaults tonil.disabled(:boolean) - Defaults tofalse.readonly(:boolean) - Defaults tofalse.required(:boolean) - Defaults tofalse.class(:string) - Applied to the<input>itself. Defaults tonil.container_class(:string) - Defaults tonil.- Global attributes are accepted. Supports all globals plus:
["autocomplete", "autofocus", "list", "max", "maxlength", "min", "minlength", "pattern", "step", "inputmode", "form"].
Slots
icon- Rendered inside the field on the leading edge.trailing- Rendered inside the field on the trailing edge — a button, say.