Skip to main content

Installation

The Form component is built on top of React Hook Form and Zod for schema validation.
Or use the CLI:

Usage

Create a form schema

Define your form schema using Zod:

Define a form

Use the useForm hook from React Hook Form to create a form:

Build your form

Compose form fields using the Form components:

Component API

Form

The root form provider built on React Hook Form’s FormProvider. Props:
  • All props from React Hook Form’s FormProvider

FormField

A controlled form field. Props:
  • control - Form control from useForm
  • name - Field name
  • render - Render function that receives field props

FormItem

Container for a form field.

FormLabel

Label for a form field. Props:
  • Automatically shows error state

FormControl

Wrapper for the form control element. Props:
  • Automatically handles id, aria-describedby, and aria-invalid

FormDescription

Description text for a form field.

FormMessage

Displays form field errors. Props:
  • Automatically displays the error message for the field

useFormField

A custom hook to access form field context. Returns:
  • id - Field ID
  • name - Field name
  • formItemId - Form item ID
  • formDescriptionId - Description ID
  • formMessageId - Message ID
  • error - Field error
  • invalid - Whether field is invalid
  • isDirty - Whether field is dirty
  • isTouched - Whether field is touched

Examples

Input

A simple form with an input field:

Textarea

A form with a textarea:

Checkbox

A form with a checkbox:

Select

A form with a select:

Radio Group

A form with a radio group:

Switch

A form with a switch:

Accessibility

  • Built on React Hook Form for performance
  • Automatic error handling and display
  • Proper ARIA attributes
  • Label associations
  • Error announcements for screen readers

API Reference

See the React Hook Form and Zod documentation for complete API details.