Forms/Smart Form
SmartForm
Pass a Zod schema and get a fully wired form — field components, validation, error display, and loading state. No react-hook-form setup, no manual error wiring.
import { SmartForm, FormField, FormSubmit } from "@animui/ui"Contact form example
Try submitting with empty or invalid fields to see validation.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
schema | ZodSchema | — | A Zod schema object. SmartForm infers field types and validation rules automatically. |
onSubmit | (data: z.infer<typeof schema>) => Promise<void> | — | Called with validated form data on submit. SmartForm shows a loading state during the async operation. |
defaultValues | Partial<z.infer<typeof schema>> | — | Pre-fill form fields with initial values. |
resetOnSuccess | boolean | false | Resets all fields to defaultValues after a successful submit. |
className | string | — | Additional classes on the form element. |