Form

Forms

A form wrapper component that provides validation context and submission handling. Works with FormField components for structured form layouts.

Import

import { 
  Form, 
  FormField, 
  FormLabel, 
  FormDescription, 
  FormMessage, 
  FormSubmit 
} from "@/components/ui/form";

Usage

Basic Form

Form with validation and submission handling

We'll never share your email.

Contact Form

Multi-field contact form example

Form Components Reference

Available form building blocks

FormField

Wrapper for individual form fields. Provides context for validation errors.

FormLabel

Label component with optional required indicator.

FormDescription

Helper text displayed below the input field.

FormMessage

Displays validation error messages automatically from context.

FormSubmit

Submit button that shows loading state during submission.

API Reference

PropTypeDefaultDescription
onSubmit(data: FormData) => void | Promise<void>undefinedCallback when form is submitted
onValidate(data: FormData) => Record<string, string>undefinedValidation function returning errors object
children*ReactNodeForm content including FormField components

Related Components