Auto Form
Component creates form based on Zod schemas & react-hook-form with validation
Basic Usage
Zod Schema Configuration
Auto Form is deeply integrated with Zod, supporting Zod validators. HTML input attributes are automatically applied based on your schema constraints.
Required vs Optional Fields
By default, all fields are required. Make a field optional using the optional
method:
Default Values
Set default values for fields using the default
method:
Advanced Validation
Auto Form supports all Zod validators:
Form Submission
To activate submit button and handle form submission with the onSubmit
callback:
Accessing the Form Instance
The onSubmit
callback provides access to the React Hook Form instance as a second parameter:
You can also define the submission handler separately:
Customizing the Submit Button
Customize the submit button using the submitButtonProps
:
Form Layout and Styling
You can control the form layout using standard CSS techniques: