Skip to main content
The Form component wraps a native <form> element with enhanced validation, error handling, and submission features.

Import

Basic Usage

Key Props

  • onFormSubmit: Called when the form is valid and submitted. Receives form values as an object and event details. Automatically calls preventDefault() on the submit event.
  • validationMode: Global validation mode for all fields - 'onSubmit' | 'onBlur' | 'onChange' (default: 'onSubmit')
  • errors: External validation errors (e.g., from server). Object where keys match field name props.
  • actionsRef: Ref to imperative actions like validate()

Validation Modes

On Submit (Default)

Validates all fields when the form is submitted, then re-validates on change:

On Blur

Validates each field when it loses focus:

On Change

Validates each field on every change:

Per-field Override

Individual fields can override the form’s validation mode:

Server-side Validation

Display errors returned from the server:
The errors prop should be an object where:
  • Keys match the name prop on Field.Root
  • Values are error messages (strings)

Custom Validation

Submission Handling

The form automatically:
  • Calls preventDefault() on submit
  • Validates all fields before submission
  • Focuses the first invalid field if validation fails
  • Only calls onFormSubmit if all fields are valid

Imperative API

Trigger validation programmatically:

Styling