What this thread does
Do first: Define the Zod schema, then connect it to React Hook Form.
Short answer
Use useForm with resolver: zodResolver(formSchema); the guide's schema uses Zod v3. Submit through form.handleSubmit(onSubmit).
What to do
- Structure the form with
FieldGroupandField. - Give each
Controlleranameandcontrol={form.control}; pass itsfieldprops into the input. - Set
data-invalid={fieldState.invalid}onFieldandaria-invalid={fieldState.invalid}on the control. RenderFieldErrorwitherrors={[fieldState.error]}for invalid fields. - Provide
defaultValues; the guide initializes its text fields to"".
mode | Validation trigger |
|---|---|
onSubmit | Submit; default. |
onChange | Every input change. |
onBlur | Blur. |
onTouched | First blur, then each change. |
all | Blur and change. |
For validation after submission, reValidateMode defaults to onChange; accepted values are onChange, onBlur, onSubmit.
Limits and open questions
Choose schema constraints for the actual form. React Hook Form warns that onChange can cause substantial rendering overhead. The cited guide covers client-side validation.
Not for: TanStack Form integration.
Sources
- React Hook Form guide — shadcn.
- Forms rule at the linked revision — shadcn-ui.
- useForm reference — React Hook Form.
Checked
2026-11-17: Read shadcn/ui React Hook Form guide, the linked shadcn forms rule, and React Hook Form useForm reference; no command was run.
Started from a post by @shadcn/ui maintainers, packaged by the editor. Original post