Skip to main content

TextField

A versatile text input supporting labels, helper text, validation, passwords, multiline, and number formatting.

Basic Usage

Variants

Sizes

Error State

Helper Text

Password

Multiline

Shapes

Prefix & Suffix

prefix / suffix render inline content inside the field — useful for currency symbols, units, or trailing actions.

$
kg

Character Count

Props

PropTypeDefaultDescription
type'text' | 'tel' | 'password' | 'number' | 'email' | 'url' | 'search''text'Input type
variant'outlined' | 'filled''outlined'Visual variant
size'sm' | 'md' | 'lg''md'Size of the field
shape'square' | 'rounded' | 'pill''square'Shape of the input border
labelstring-Label displayed above the input
placeholderstring-Placeholder text
helperTextstring-Helper text displayed below the input
errorbooleanfalseWhether the field is in error state
errorMessagestring-Error message displayed below the input
requiredbooleanfalseWhether the field is required (shows red asterisk)
disabledbooleanfalseWhether the field is disabled
fullWidthbooleanfalseStretches the field to fill its container
multilinebooleanfalseRenders a textarea instead of input
rowsnumber3Number of rows for textarea
format'currency' | 'decimal'-Auto-formatting for number type
onValueChange(rawValue: string) => void-Callback with unformatted value
prefixReactNode-Content before the input
suffixReactNode-Content after the input
maxLengthnumber-Maximum character count (shows counter)

Also accepts all standard <input> HTML attributes.

Mobile considerations

  • iOS Safari auto-zooms any input with font-size < 16px on focus. trust-ui's mobile font scale automatically bumps --tui-font-size-md up to 16px on pointer:coarse devices to prevent this — no extra config needed.
  • For type="tel" / type="email" / type="url" / type="number", iOS shows the right software keyboard automatically.
  • When the keyboard appears, wrap the form in <KeyboardAvoidingView> so the focused field stays visible above the keyboard.
  • multiline textarea respects the same auto-zoom prevention.