ComponentsLumos 0.0.2NewOpen component

Input

A single-line field that settles its own type, keyboard and autofill.

Most of what makes a field work is decided by four attributes that have to agree: type, inputmode, autocomplete and the label. Get one wrong and a phone field opens a letter keyboard, or an email field is never autofilled. Input takes one prop instead — variant — and settles all four together.

astro
<Input variant="email" required />
<Input variant="phone" />
<Input label="Company" />

Each variant brings its own label and placeholder, so a field only has to say which one it is. Set label when yours needs different wording.

Variants

VariantField typeWhat it brings
texttextNo assumptions. The default, for anything the list does not cover.
first-name, last-nametextAutofilled from a saved address.
emailemailThe email keyboard, and the browser's own validation.
phonetelThe number pad.
urlurlThe URL keyboard, and validation.
numbernumberThe numeric keyboard. Autofill off.
datedateThe browser's date picker.
zip-codetextThe numeric keyboard, autofilled from an address.
searchsearchThe browser's search handling, including the clear button.
passwordpasswordMasked, and offered to the password manager.

Props

PropTypeDefaultWhat it does
renderbooleantrueSet to false to skip this component and everything inside it.
variant"text" | "first-name" | "last-name" | "email" | "phone" | "date" | "zip-code" | "number" | "search" | "password" | "url""text"What the field is for. It settles the input's type, keyboard, autofill and wording together.
labelstringNoneThe text above the field. Defaults to the wording of the variant.
valuestringNoneWhat the field starts out holding.
namestringNoneThe name it submits under. Taken from the label where it is not set.
placeholderstringNoneThe text shown in an empty field. Defaults to the wording of the variant.
requiredbooleanfalseMarks the field as needed, and stars its label.
labelHiddenbooleanfalseKeeps the label for a screen reader, and takes it off the page.