TextField

Text fields let people enter text into a UI.

Usage

TextField lets users enter and edit text. It supports controlled (value) and uncontrolled (defaultValue) usage, and switches to a multiline textarea, a date picker, or a select menu depending on multiline/type. In Svelte, use bind:value for the bindable value surface.

Variants

  • filled (default)
  • outlined

Styling the root and internal elements

A string targets the root: className in React, the native class attribute in Angular, or class in Svelte. To reach an internal element (input, label, supportingText, …), pass an object keyed by element name — className={{ … }} in React, [classes]="{ … }" in Angular, or classes={{ … }} in Svelte. A function receiving the resolved props and states is also accepted for the rare cases that depend on what only the component knows. Consumer classes are merged after the defaults with tailwind-merge, so bg-*, text-* and similar utilities override cleanly.

Uppercase letters only

Leading/trailing icon and suffix

Use leadingIcon, trailingIcon, or suffix for extra affordances. Both are agnostic Icon data, rendered identically in all three frameworks; there is no escape hatch for an arbitrary interactive node.

Multi-line

Set multiline for an auto-growing textarea. The auto-grow behavior is implemented once as a shared @udixio/core/dom controller, so all three adapters resize identically.

Error and supporting text

Show validation and helper text with errorText and supportingText.

Use 3–16 characters

Password is too short

Controlled vs uncontrolled

Use value with onChange in React, [(value)] in Angular, or bind:value in Svelte. defaultValue initializes uncontrolled usage.

Select mode

type="select" opens a menu of options instead of a native input. React additionally accepts projected MenuItem children in place of options; Angular and Svelte use options.

Date mode

type="date" opens a DatePicker popover and stores the selection as an ISO YYYY-MM-DD string. The field stays directly typable in that same format; only select mode is read-only. Svelte owns the equivalent calendar surface inside TextField rather than exposing a separate DatePicker component.

Custom mask

Pass mask to transform typed or pasted input on every keystroke – for any format an app needs, not just dates: a phone number, a card number, a multi-group ID. It defaults to the built-in YYYY-MM-DD mask for type="date"; providing one always overrides it, for that type or any other.

The field is controlled, so mask receives its own previous output back as raw on every subsequent keystroke – it must be idempotent (mask(mask(x)) === mask(x)). Inserted separators the user never typed (a space, a dash) are safe, since a naive filter already excludes them from the next pass – but a literal that contains digits (a +33 country code, a fixed digit group) will be mistaken for freshly typed input on the next call unless you strip it back out first.

Accessibility

aria-describedby links the supporting text/error row to the input, and aria-invalid reflects errorText. The date/select trailing icon renders as a real <button> so it stays reachable by keyboard, independent of the field’s own click-to-open behavior. Svelte’s select popup exposes listbox/option semantics and its calendar exposes the shared grid/gridcell structure.