Summary
Form wrapper integrating react-hook-form + zod for validated forms with accessible error messages. Present in shadcn/ui. Eliminates manual wiring for every form.
Proposed API
const schema = z.object({
email: z.string().email(),
name: z.string().min(2),
})
<Form schema={schema} onSubmit={handleSubmit} defaultValues={{ email: "", name: "" }}>
<FormField name="email">
<FormLabel>Email</FormLabel>
<FormControl>
<Input placeholder="you@example.com" />
</FormControl>
<FormDescription>Your work email address</FormDescription>
<FormMessage /> {/* auto-shows validation error */}
</FormField>
<FormField name="name">
<FormLabel>Name</FormLabel>
<FormControl>
<Input />
</FormControl>
<FormMessage />
</FormField>
<Button type="submit">Submit</Button>
</Form>
Requirements
Technical Notes
- react-hook-form + @hookform/resolvers + zod as peer deps
- Context-based: FormField provides field state to children
- Follow shadcn/ui Form pattern closely
References
Summary
Form wrapper integrating react-hook-form + zod for validated forms with accessible error messages. Present in shadcn/ui. Eliminates manual wiring for every form.
Proposed API
Requirements
Technical Notes
References