Skip to content

TextField

A wrapper around React Aria’s TextField component. Manages label association, validation state, and error messages automatically.

Terminal window
npx @a2ra/cli add text-field
{
"type": "TextField",
"props": {
"label": "Email address",
"type": "email",
"name": "email",
"isRequired": true,
"description": "We'll never share your email."
}
}
PropTypeDescription
labelstringVisible label (required for accessibility)
placeholderstringPlaceholder text
typetext default
email
password
number
tel
url
Input type
namestringForm field name
valuestringControlled value
defaultValuestringUncontrolled default
autoCompletestringBrowser autocomplete hint
inputModetext
numeric
decimal
email
tel
url
search
Virtual keyboard hint
minLengthnumberMinimum character length
maxLengthnumberMaximum character length
patternstringRegex validation pattern
isDisabledtrue
false default
Disables the input
isRequiredtrue
false default
Marks field as required
isReadOnlytrue
false default
Prevents editing
isInvalidtrue
false default
Shows error styling
autoFocustrue
false default
Focuses the field on mount
validationBehavioraria default
native
Validation reporting strategy
descriptionstringHelper text shown below the input
errorMessagestringError text shown when isInvalid is true
  • Always provide a label. React Aria associates it with the input via ARIA attributes.
  • errorMessage is only shown when isInvalid: true.
  • Use validationBehavior: "native" for HTML form constraint validation with browser-native messages.