Form

A native form element with consolidated error handling.

API reference

Form is composed together with Field. Import the components and place them together:

Anatomy
PropTypeDefault
errors

Errors

undefined

onClearErrors

((errors: Errors) => void)

undefined

className

string | ((state: State) => string)

undefined

render

| ReactElement
| ((props: GenericHTMLProps, state: State) => ReactElement)

undefined

Examples

Using with Zod

When parsing the schema using schema.safeParse(), the result.error.flatten().fieldErrors data can be used to map the errors to each field’s name.