checkbox-form-multiple.json — ui Source File
Architecture documentation for checkbox-form-multiple.json, a json file in the ui codebase.
Entity Profile
Source Code
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "checkbox-form-multiple",
"registryDependencies": [
"checkbox",
"form"
],
"files": [
{
"path": "registry/new-york-v4/examples/checkbox-form-multiple.tsx",
"content": "\"use client\"\n\nimport { zodResolver } from \"@hookform/resolvers/zod\"\nimport { useForm } from \"react-hook-form\"\nimport { toast } from \"sonner\"\nimport { z } from \"zod\"\n\nimport { Button } from \"@/registry/new-york-v4/ui/button\"\nimport { Checkbox } from \"@/registry/new-york-v4/ui/checkbox\"\nimport {\n Form,\n FormControl,\n FormDescription,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n} from \"@/registry/new-york-v4/ui/form\"\n\nconst items = [\n {\n id: \"recents\",\n label: \"Recents\",\n },\n {\n id: \"home\",\n label: \"Home\",\n },\n {\n id: \"applications\",\n label: \"Applications\",\n },\n {\n id: \"desktop\",\n label: \"Desktop\",\n },\n {\n id: \"downloads\",\n label: \"Downloads\",\n },\n {\n id: \"documents\",\n label: \"Documents\",\n },\n] as const\n\nconst FormSchema = z.object({\n items: z.array(z.string()).refine((value) => value.some((item) => item), {\n message: \"You have to select at least one item.\",\n }),\n})\n\nexport default function CheckboxReactHookFormMultiple() {\n const form = useForm<z.infer<typeof FormSchema>>({\n resolver: zodResolver(FormSchema),\n defaultValues: {\n items: [\"recents\", \"home\"],\n },\n })\n\n function onSubmit(data: z.infer<typeof FormSchema>) {\n toast(\"You submitted the following values\", {\n description: (\n <pre className=\"mt-2 w-[320px] rounded-md bg-neutral-950 p-4\">\n <code className=\"text-white\">{JSON.stringify(data, null, 2)}</code>\n </pre>\n ),\n })\n }\n\n return (\n <Form {...form}>\n <form onSubmit={form.handleSubmit(onSubmit)} className=\"space-y-8\">\n <FormField\n control={form.control}\n name=\"items\"\n render={() => (\n <FormItem>\n <div className=\"mb-4\">\n <FormLabel className=\"text-base\">Sidebar</FormLabel>\n <FormDescription>\n Select the items you want to display in the sidebar.\n </FormDescription>\n </div>\n {items.map((item) => (\n <FormField\n key={item.id}\n control={form.control}\n name=\"items\"\n render={({ field }) => {\n return (\n <FormItem\n key={item.id}\n className=\"flex flex-row items-center gap-2\"\n >\n <FormControl>\n <Checkbox\n checked={field.value?.includes(item.id)}\n onCheckedChange={(checked) => {\n return checked\n ? field.onChange([...field.value, item.id])\n : field.onChange(\n field.value?.filter(\n (value) => value !== item.id\n )\n )\n }}\n />\n </FormControl>\n <FormLabel className=\"text-sm font-normal\">\n {item.label}\n </FormLabel>\n </FormItem>\n )\n }}\n />\n ))}\n <FormMessage />\n </FormItem>\n )}\n />\n <Button type=\"submit\">Submit</Button>\n </form>\n </Form>\n )\n}\n",
"type": "registry:example"
}
],
"type": "registry:example"
}
Source
Frequently Asked Questions
What does checkbox-form-multiple.json do?
checkbox-form-multiple.json is a source file in the ui codebase, written in json.
Where is checkbox-form-multiple.json in the architecture?
checkbox-form-multiple.json is located at apps/v4/public/r/styles/new-york-v4/checkbox-form-multiple.json (directory: apps/v4/public/r/styles/new-york-v4).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free