ComponentClient component

Form

Accessible react-hook-form bindings for controls, descriptions and validation messages.

Installation

Preview

We will only send release notes.

Usage

tsx
import { useForm } from "react-hook-form"
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "@/components/ui/form"
import { Input } from "@/components/ui/input"

const form = useForm({ defaultValues: { email: "" } })

<Form {...form}>
  <form onSubmit={form.handleSubmit(console.log)}>
    <FormField control={form.control} name="email" render={({ field }) => (
      <FormItem>
        <FormLabel>Email</FormLabel>
        <FormControl><Input {...field} /></FormControl>
        <FormMessage />
      </FormItem>
    )} />
  </form>
</Form>

API reference

PropTypeDefaultDescription
controlControl<TFieldValues>The react-hook-form control instance.
nameFieldPath<TFieldValues>The strongly typed field path.
classNamestringOverrides or extends the generated Tailwind classes.
disabledbooleanfalsePrevents user interaction when supported.