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.
Import
Section titled “Import”<script> import TextField from "@invisible-ui/svelte/TextField.svelte";</script><script setup> import { TextField } from "@invisible-ui/vue";</script>import { TextField } from "@invisible-ui/react";<script type="module"> import "@invisible-ui/elements/define";</script>
<ds-text-field></ds-text-field>Native constraints
Section titled “Native constraints”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.
| Prop | Type | Default | Description |
|---|---|---|---|
label * | string | — | Visible label, tied to the control. |
hideLabel | boolean | false | Visually hide the label while keeping it as the control's accessible name. |
value | string | "" | Field value. |
type | InputType | "text" | Input type. |
placeholder | string | undefined | undefined | Placeholder text. |
description | string | undefined | undefined | Hint shown under the control, linked via aria-describedby. |
error | string | undefined | undefined | When non-empty the field becomes invalid and announces the message. |
success | string | undefined | undefined | Success/validated message; shows a green check and a confirming caption. |
disabled | boolean | false | Disable the field. |
required | boolean | false | Mark as required. |
readOnly | boolean | false | Make the field read-only. |
name | string | undefined | undefined | Form field name — the value is submitted under it. |
maxlength | number | undefined | undefined | Native length limits; the browser enforces them and reports them. |
minlength | number | undefined | undefined | |
pattern | string | undefined | undefined | Native format constraint (paired with title for the browser's message). |
inputmode | InputMode | undefined | undefined | Keyboard hint on touch devices. |
autocomplete | HTMLInputAttributes["autocomplete"] | undefined | undefined | Autofill hint, e.g. "email" or "one-time-code". |
spellcheck | boolean | undefined | undefined | Turn spelling correction off for codes and identifiers. |
onValueChange | ((value: string) => void) | undefined | undefined | Called whenever the value changes. |
left | Snippet | undefined | undefined | A decorative icon before the control. |
right | Snippet | undefined | undefined | A decorative icon after the control; replaces the built-in success check. |
| Prop | Type | Default | Description |
|---|---|---|---|
label * | string | — | Visible label, tied to the control. |
hideLabel | boolean | false | Visually hide the label while keeping it as the control's accessible name. |
modelValue | string | undefined | v-model value; takes precedence over value when bound. |
value | string | "" | |
type | InputType | "text" | |
placeholder | string | undefined | |
description | string | undefined | Optional hint shown under the control and linked via aria-describedby. |
error | string | undefined | Error message; when non-empty the field becomes invalid and announces it. |
success | string | undefined | Success/validated message; shows a green check and a confirming caption. |
disabled | boolean | false | |
required | boolean | false | |
readOnly | boolean | false | |
name | string | undefined | Form field name; the value is submitted under it. |
maxlength | number | undefined | Native length limits; the browser enforces them and reports them. |
minlength | number | undefined | |
pattern | string | undefined | Native format constraint (paired with title for the browser's message). |
inputmode | TextFieldProps["inputmode"] | undefined | Keyboard hint on touch devices. |
autocomplete | string | undefined | Autofill hint, e.g. "email" or "one-time-code". |
spellcheck | boolean | undefined | Turn spelling correction off for codes and identifiers. |
onValueChange | (value: string) => void | undefined | Called whenever the value changes. |
| Event | Payload |
|---|---|
update:modelValue | value: string |
Slots: left, right.
| Prop | Type | Default | Description |
|---|---|---|---|
label * | string | — | Visible label and accessible name for the control. |
hideLabel | boolean | false | Visually hide the label while keeping it as the control's accessible name. |
value | string | "" | Initial or current value. |
type | InputType | "text" | Native input type. |
placeholder | string | — | Native placeholder. It does not replace the label. |
description | string | — | Hint linked to the control through aria-describedby. |
error | string | — | Error message that marks the control invalid and is announced. |
success | string | — | Confirmation message announced politely when the field is valid. |
disabled | boolean | false | Prevent interaction and form submission. |
required | boolean | false | Mark the native input as required. |
readOnly | boolean | false | Keep the input focusable and submittable but prevent edits. |
name | string | — | Native form field name. |
maxLength | number | — | Native maximum length constraint. |
minLength | number | — | Native minimum length constraint. |
pattern | string | — | Native validation pattern. |
inputMode | InputHTMLAttributes<HTMLInputElement>["inputMode"] | — | Preferred virtual keyboard mode. |
autoComplete | InputHTMLAttributes<HTMLInputElement>["autoComplete"] | — | Native autofill hint. |
spellCheck | boolean | — | Enable or disable browser spelling correction. |
onValueChange | (value: string) => void | — | Called once after a user edit is committed locally. |
left | ReactNode | — | Decorative content placed inside the control at the inline start. |
right | ReactNode | — | Decorative content placed inside the control at the inline end. |
| Attribute | Reactive | Description |
|---|---|---|
label * | yes | |
hide-label | yes | |
value | yes | |
placeholder | yes | |
description | yes | |
error | yes | |
success | yes | |
required | yes | |
disabled | yes | |
readonly | yes | |
name | yes | |
type | yes | |
autocomplete | yes |
Reactive attributes re-render the element when they change after the first render.
Properties: value.
Emits: bubbling input and change CustomEvents, both with detail.value.
Hidden labels
Section titled “Hidden labels”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.
Accessibility
Section titled “Accessibility”- Label association plus
aria-describedby(hint and error),aria-invalid,aria-requiredcome from the headless text field. - A hidden label remains the input’s accessible name.
- A non-empty
errorputs the field in the invalid state and announces the message.
Example
Section titled “Example”<TextField label="Email" type="email" description="We'll never share it." onValueChange={(v) => (email = v)}/>Themeable via --ds-field-*.