Form
A wrapper around React Aria’s Form component. Handles server-side validation errors,
form-wide disabled state, and vertical spacing between fields.
Add via CLI
Section titled “Add via CLI”npx @a2ra/cli add formWith server validation
Section titled “With server validation”Example JSON
Section titled “Example JSON”{ "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" } ]}| Prop | Type | Description |
|---|---|---|
gap | smmd defaultlg | Vertical spacing between child fields |
validationBehavior | aria defaultnative | Validation reporting strategy |
validationErrors | Record<string, string | string[]> | Server-side errors keyed by field name |
action | string | Form action URL |
method | getpost | HTTP method |
encType | string | Encoding type |
autoComplete | onoff | Browser autocomplete hint |
target | string | Form submission target |
children | node[] | Form field nodes |
validationErrorskeys must match thenameprop of the field they target.- Use
validationBehavior: "native"when submitting to a plain HTML form endpoint. Formdoes not submit on its own. Pair it with aButtonwithtype: "submit".