Single-line text field: outlined, filled or plain, rounded or pill, three sizes, icon,
prefix and suffix, states, masks.
<.input field={@form[:name]} label="Nome" />
<.input field={@form[:total]} align="right" label="Total"><:prefix text>R$</:prefix></.input>
<.input field={@form[:email]} type="email" variant="filled" size="lg" state="success" help="E-mail verificado" />
<.input field={@form[:q]} shape="pill" layout="inline" label="Buscar" label_hint="opcional" />field={@form[:name]} fills id, name, value and errors. With errors the help line shows
the messages and the box turns red.
Masks
mask formats what is typed (hook LedgerUI.InputMask, which needs a stable id; it comes
from field):
<.input name="doc" mask="cpf_cnpj" label="CPF ou CNPJ" mask_submit="raw" />
<.input name="amount" mask="numeral" mask_options={%{thousands: "lakh"}} />
<.input name="code" mask="blocks" mask_options={%{blocks: [3, 2, 3], delimiter: "-", uppercase: true}} />| mask | options |
|---|---|
blocks | blocks, delimiter, delimiters, prefix, uppercase, lowercase, numeric |
credit_card | delimiter |
date | pattern (~w(d m Y)), delimiter |
time | pattern (~w(h m s)), delimiter |
phone | blocks, delimiter |
cpf_cnpj | none |
numeral | thousands, decimals, delimiter, decimal_mark, positive, prefix |
The input submits the masked text; mask_submit="raw" submits the unmasked value through a
hidden input that carries the field's name.
Slots
:prefix and :suffix hold an icon (or, with text, an addon such as R$, %, .com.br);
interactive puts a button there. :label_aside goes at the right of the caption and :below
between the box and the help line.
Inside an input_group use variant="plain": the group draws the shared border.
Summary
Functions
Renders a text-like <input>, with its caption, help and errors when given.
Functions
Renders a text-like <input>, with its caption, help and errors when given.
Attributes
field(Phoenix.HTML.FormField) - A form field: fills id/name/value/errors. Defaults tonil.id(:string) - Defaults tonil.name(:string) - Defaults tonil.value(:any) - Defaults tonil.type(:string) - Defaults to"text". Must be one of"text","email","password","number","search","tel","url","date","time","datetime-local","month","week","color","file", or"hidden".variant(:string) - Defaults to"outlined". Must be one of"outlined","filled", or"plain".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".align(:string) - Defaults to"left". Must be one of"left", or"right".state(:string) - Defaults tonil.Must be one ofnil,"","success", or"error".label(:string) - Defaults tonil.label_class(:any) - Defaults tonil.label_hint(:string) - Defaults tonil.layout(:string) - Defaults to"stacked". Must be one of"stacked", or"inline".help(:string) - Defaults tonil.errors(:list) - Defaults to[].disabled(:boolean) - Defaults tofalse.options(:list) - Suggestions, rendered as the input's<datalist>. Defaults to[].icon(:string) - Icon name at the left of the text. Defaults tonil.mask(:string) - Defaults tonil.Must be one ofnil,"","blocks","credit_card","date","time","phone","numeral", or"cpf_cnpj".mask_options(:map) - Defaults to%{}.mask_submit(:string) - Defaults to"formatted". Must be one of"formatted", or"raw".clear_on_submit(:boolean) - Defaults tofalse.wrapper_class(:any) - Defaults tonil.class(:any) - Defaults tonil.- Global attributes are accepted. Supports all globals plus:
["accept", "autocomplete", "autofocus", "form", "list", "max", "maxlength", "min", "minlength", "multiple", "pattern", "placeholder", "readonly", "required", "step", "inputmode", "size"].
Slots
belowlabel_asideprefix- Accepts attributes:interactive(:boolean)text(:boolean)class(:any)
suffix- Accepts attributes:interactive(:boolean)text(:boolean)class(:any)