Skip to content

Form

Form

React Hook Form integration with Zod validation and accessible error messages.

Zod validationInline errorsSubmission feedback
Open preview

Responsive viewport — resize the window to explore. Direction and density apply only to this preview. Theme applies to the docs too.

Usage

Create a form with useForm and a Zod resolver, then pass the methods to Form. Compose FormField, FormItem, FormLabel, FormControl, FormDescription, and FormMessage for each field.

Import
import {
  Form,
  FormField,
  FormItem,
  FormLabel,
  FormControl,
  FormDescription,
  FormMessage,
} from "@dashboardpack/core/components/ui/form";

Available in the included @dashboardpack/core package. Copy the complete example from Source code for all imports and state. Add "use client" when using hooks or event handlers. See installation and theming for project setup.

API reference

Common props and defaults. Slot-specific props are named below; native elements also accept their standard HTML attributes. The component TypeScript definitions are the complete type reference.

Form props
PropType / DefaultDescription
...methods (Form)UseFormReturn

Default: required

FormProvider receives useForm methods.
control (FormField)Control<T>

Default: required

The form’s control object.
name (FormField)FieldPath<T>

Default: required

Registered field name.
render (FormField)Controller render callback

Default: required

Return the labeled field composition.
children (FormMessage)ReactNode

Default: field error

Optional custom error message.

Build with these too