Skip to content

Form

A wrapper around React Aria’s Form component. Handles server-side validation errors, form-wide disabled state, and vertical spacing between fields.

Terminal window
npx @a2ra/cli add form
{
"type": "Form",
"props": { "gap": "md" },
"children": [
{ "type": "TextField", "props": { "label": "Full name", "name": "name", "isRequired": true } },
{ "type": "TextField", "props": { "label": "Email", "name": "email", "type": "email", "isRequired": true } },
{ "type": "Button", "props": { "variant": "primary", "type": "submit" }, "children": "Create account" }
]
}
PropTypeDescription
gapsm
md default
lg
Vertical spacing between child fields
validationBehavioraria default
native
Validation reporting strategy
validationErrorsRecord<string, string | string[]>Server-side errors keyed by field name
actionstringForm action URL
methodget
post
HTTP method
encTypestringEncoding type
autoCompleteon
off
Browser autocomplete hint
targetstringForm submission target
childrennode[]Form field nodes
  • validationErrors keys must match the name prop of the field they target.
  • Use validationBehavior: "native" when submitting to a plain HTML form endpoint.
  • Form does not submit on its own. Pair it with a Button with type: "submit".