Form

Accessible form fields with react-hook-form and zod validation. Handles labels, descriptions, and error messages with correct ARIA wiring.

Setup

Import Form primitives and wire up a schema — see the code tab.

Profile form

This is your public display name.

Max 160 characters.

Validation errors

API

PropTypeDefaultDescription
FormFormProviderWraps the form. Spread useForm() return value into it.
FormFieldControllerPropsConnects a field to react-hook-form via render prop. Provides field state via context.
FormItemdivContainer for a single field group. Generates a unique id shared by label, input, and messages.
FormLabellabelLabel for the field. Turns red when the field has an error.
FormControldivWrapper around the actual input. Wires up aria-describedby and aria-invalid.
FormDescriptionpHelper text shown below the input.
FormMessagepShows the zod validation error for this field. Renders nothing when there is no error.