{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "calendar-form", "type": "registry:example", "author": "shadcn (https://ui.shadcn.com)", "registryDependencies": [ "calendar", "form", "popover" ], "files": [ { "path": "examples/calendar-form.tsx", "content": "\"use client\"\n\nimport { zodResolver } from \"@hookform/resolvers/zod\"\nimport { format } from \"date-fns\"\nimport { CalendarIcon } from \"lucide-react\"\nimport { useForm } from \"react-hook-form\"\nimport { z } from \"zod\"\n\nimport { cn } from \"@/lib/utils\"\nimport { toast } from \"@/registry/default/hooks/use-toast\"\nimport { Button } from \"@/registry/default/ui/button\"\nimport { Calendar } from \"@/registry/default/ui/calendar\"\nimport {\n Form,\n FormControl,\n FormDescription,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n} from \"@/registry/default/ui/form\"\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from \"@/registry/default/ui/popover\"\n\nconst FormSchema = z.object({\n dob: z.date({\n required_error: \"A date of birth is required.\",\n }),\n})\n\nexport default function CalendarForm() {\n const form = useForm>({\n resolver: zodResolver(FormSchema),\n })\n\n function onSubmit(data: z.infer) {\n toast({\n title: \"You submitted the following values:\",\n description: (\n
\n          {JSON.stringify(data, null, 2)}\n        
\n ),\n })\n }\n\n return (\n
\n \n (\n \n Date of birth\n \n \n \n \n {field.value ? (\n format(field.value, \"PPP\")\n ) : (\n Pick a date\n )}\n \n \n \n \n \n \n date > new Date() || date < new Date(\"1900-01-01\")\n }\n initialFocus\n />\n \n \n \n Your date of birth is used to calculate your age.\n \n \n \n )}\n />\n \n \n \n )\n}\n", "type": "registry:example", "target": "" } ] }