Forms / Text field

Forms

Text field

Labelled inputs with required marks, one line of help, and the two-up field grid.

import { EcoTextField, EcoField, EcoFieldGrid } from "vue-ecosphere"

Field

A label, a required mark and an example placeholder.

Value: ""

Filled

Value: "Kiara Casmer"

Grid

fgrid puts two fields side by side.

Hint and error

One line of help. The error replaces the hint while the value is wrong — add a domain to see the hint come back.

That address is missing a domain, like .com.

Password with reveal

The eye button swaps the input between password and text; the end of the box is its, so iconEnd is ignored.

Your own control in a field

EcoField wraps any control with the label and help line.

Shown in the sidebar.

EcoTextField

NameTypeDefaultDescription
v-modelstring""The input's value.
labelstring—Field label (field__l), wired to the input with for/id.
requiredbooleanfalseAdds the req mark after the label.
hintstring—One line of help: the format or the range.
errorstring—Replaces the hint and sets aria-invalid. Never stack the two.
invalidbooleanfalseInvalid without a message.
type"text" | "email" | "password" | "tel" | "url" | "search" | "number""text"Native input type.
placeholderstring—An example value, never the label.
iconstring—Leading glyph inside the box (ifield + ifield__ico). Inert.
iconEndstring—Trailing glyph inside the box (ifield--end). Ignored while reveal shows its button.
revealbooleanfalseWith type="password": an eye button at the end of the box shows and hides the value (aria-pressed while shown).
showLabel / hideLabelstring"Show password" / "Hide password"Accessible name of the reveal button while the value is hidden / shown.
firstbooleanfalseFirst field in its container: drops the top margin (field--first).
disabled / readonlybooleanfalsePair disabled with a hint that says why.
idstring—Input id; generated when omitted.
…attrs——name, autocomplete, inputmode and listeners go to the <input>; class/style to the field.

EcoField

NameTypeDefaultDescription
label / required / hint / error / first——As on EcoTextField.
forstring—Id of your control: renders a <label for>. Without it the label is a <span>.
labelId / describedIdstring—Ids for aria-labelledby and aria-describedby on your control.
slotsdefault · label · hint · error · foot · after—The control goes in the default slot; foot replaces the hint/error line.

EcoFieldGrid

NameTypeDefaultDescription
firstbooleanfalseFirst thing in its container: drops the top margin (fgrid--first).
default slot——Two fields; their own top margins are dropped inside the grid.