# shadcn/ui Integration Guide Complete guide for using shadcn/ui with React Hook Form + Zod. --- ## Form Component (Legacy) **Status**: "Not actively developed" according to shadcn/ui documentation **Recommendation**: Use Field component for new projects (coming soon) ### Installation ```bash npx shadcn@latest add form ``` ### Basic Usage ```typescript import { zodResolver } from '@hookform/resolvers/zod' import { useForm } from 'react-hook-form' import { z } from 'zod' import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, } from '@/components/ui/form' const schema = z.object({ username: z.string().min(2), }) function ProfileForm() { const form = useForm>({ resolver: zodResolver(schema), defaultValues: { username: '' }, }) return (
( Username Your public display name. )} /> ) } ``` --- ## Form Component Anatomy ### FormField ```typescript ( // Your field component )} /> ``` ### FormItem Container for field, label, description, and message. ```typescript Email Helper text ``` ### FormControl Wraps the actual input component. ```typescript ``` ### FormLabel Accessible label with automatic linking to input. ```typescript Email Address ``` ### FormDescription Helper text for the field. ```typescript We'll never share your email. ``` ### FormMessage Displays validation errors. ```typescript ``` --- ## Common Patterns ### Input Field ```typescript ( Email )} /> ``` ### Textarea ```typescript ( Bio