API

schema: SchemaProvider

The schema prop is used to pass the schema to the form. It can be a ZodProvider or a YupProvider.

onSubmit?: (values: T, form: FormInstance) => void

The onSubmit prop is called when the form is submitted and the data is valid. It receives the form data and the form instance from react-hook-form.

onFormInit?: (form: FormInstance) => void

The onFormInit prop is called when the form is initialized. It receives the form instance from react-hook-form.

withSubmit?: boolean

The withSubmit prop is used to automatically add a submit button to the form. It defaults to false.

defaultValues?: Partial<T>

The defaultValues prop is used to set the initial values of the form.

values: Partial<T>

The values prop is used to set the values of the form. It is a controlled input.

children: React.ReactNode

All children passed to the AutoForm component will be rendered below the form.

formComponents: Partial<AutoFormFieldComponents>

Additional, custom form components can be passed to the formComponents prop. This allows you to add custom field types to the form.

uiComponents: Partial<AutoFormUIComponents>

Override the default UI components with custom components. This allows you to customize the look and feel of the form.

formProps?: React.ComponentProps<‘form’>

The formProps prop allows you to pass additional props directly to the underlying form element. This can be useful for adding custom attributes, event handlers, or other properties to the form.