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
import { Field } from '@base-ui-components/react/field';
import { Form } from '@base-ui-components/react/form';

<Form>
  <Field.Root>
    <Field.Label />
    <Field.Control />
    <Field.Error />
  </Field.Root>
</Form>
PropTypeDefault
errors

unknown

undefined

onClearErrors

((errors: unknown) => void)

undefined

className

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

undefined

render

| ReactElement
| ((props: GenericHTMLProps, state: unknown) => 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.