Skip to content

Text Input

We'll never share it.

Enter a valid email address.

This username is available.

A styled single-line text field with label, optional description and error message.

<script>
import TextField from "@invisible-ui/svelte/TextField.svelte";
</script>

maxlength, minlength, pattern, inputmode, autocomplete and spellcheck reach the real <input>, so the browser enforces and reports them itself — a too-short value blocks submission with the platform’s own message, and a password manager or an SMS code can autofill.

<TextField label="Postcode" maxlength={8} pattern="[A-Z0-9 ]+" autocomplete="postal-code" />

For numeric entry use the Number Field: it parses the user’s locale and keeps the typed draft, which type="number" cannot do.

PropTypeDefaultDescription
label *string—Visible label, tied to the control.
hideLabelbooleanfalseVisually hide the label while keeping it as the control's accessible name.
valuestring""Field value.
typeInputType"text"Input type.
placeholderstring | undefinedundefinedPlaceholder text.
descriptionstring | undefinedundefinedHint shown under the control, linked via aria-describedby.
errorstring | undefinedundefinedWhen non-empty the field becomes invalid and announces the message.
successstring | undefinedundefinedSuccess/validated message; shows a green check and a confirming caption.
disabledbooleanfalseDisable the field.
requiredbooleanfalseMark as required.
readOnlybooleanfalseMake the field read-only.
namestring | undefinedundefinedForm field name — the value is submitted under it.
maxlengthnumber | undefinedundefinedNative length limits; the browser enforces them and reports them.
minlengthnumber | undefinedundefined
patternstring | undefinedundefinedNative format constraint (paired with title for the browser's message).
inputmodeInputMode | undefinedundefinedKeyboard hint on touch devices.
autocompleteHTMLInputAttributes["autocomplete"] | undefinedundefinedAutofill hint, e.g. "email" or "one-time-code".
spellcheckboolean | undefinedundefinedTurn spelling correction off for codes and identifiers.
onValueChange((value: string) => void) | undefinedundefinedCalled whenever the value changes.
leftSnippet | undefinedundefinedA decorative icon before the control.
rightSnippet | undefinedundefinedA decorative icon after the control; replaces the built-in success check.

Set hideLabel in Svelte, Vue or React, or hide-label on <ds-text-field>, when nearby content already makes the field’s purpose clear. The component keeps the real <label> associated with the input and hides it only visually. Do not use a placeholder as the field’s only label.

  • Label association plus aria-describedby (hint and error), aria-invalid, aria-required come from the headless text field.
  • A hidden label remains the input’s accessible name.
  • A non-empty error puts the field in the invalid state and announces the message.
<TextField
label="Email"
type="email"
description="We'll never share it."
onValueChange={(v) => (email = v)}
/>

Themeable via --ds-field-*.