Duolith docs

TextField

A labelled single-line text field with a hint or an error under it.

Stability: experimental

Props

PropTypeDefaultMeans
labelstringThe label above the field, and its accessible name.
valuestringbindable("")The text. Bind it with bind:value={name}.
placeholderstringHint text while empty.
hintstringHelp under the field.
errorstringAn error under the field; replaces the hint, turns the border red and marks the field invalid.
type"text" | "email" | "password" | "number" | "phone" | "search"textThe kind of text, which picks the keyboard.
autocompleteAutocompleteWhat the field holds, so the browser, iOS and Android can offer saved values: email, username, current-password, new-password, one-time-code, name, tel, postal-code and the other words input's autocomplete takes (decision 0106).
iconstringAn icon inside the field, before the text.
disabledbooleanfalseCannot be edited or focused.
onChange(value: string) => voidRuns when the user leaves the field after editing it.

States

StateLooks like
focusedPrimary border and a soft primary ring.
errorDanger border and ring; the error text with an alert icon.
disabledRaised background, dimmed label.

Accessibility

roletextbox
nameThe label prop.
focusTab reaches it; Shift+Tab leaves it. A disabled one is skipped.
noteserror sets aria-invalid and the message is a live alert. The field is described (aria-describedby) by the error when there is one, otherwise by the hint.

Theme tokens

color.surface color.border color.primary color.danger color.raised color.ink color.muted space.3 radius.md text.label text.caption

Example

<TextField label="Email" type="email" bind:value={email} error={emailError} />