switch-form.tsx — ui Source File
Architecture documentation for switch-form.tsx, a tsx file in the ui codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR f4c1b76a_47e3_9b5d_dfd6_e34964c1263a["switch-form.tsx"] 3d40a3bf_c062_4304_329a_00b1b72e8523["zod"] f4c1b76a_47e3_9b5d_dfd6_e34964c1263a --> 3d40a3bf_c062_4304_329a_00b1b72e8523 6d65354d_8f59_2cfc_4783_24b2eb870bc4["react-hook-form"] f4c1b76a_47e3_9b5d_dfd6_e34964c1263a --> 6d65354d_8f59_2cfc_4783_24b2eb870bc4 6802ce19_522d_e5fb_e458_8826d9f6952e["zod"] f4c1b76a_47e3_9b5d_dfd6_e34964c1263a --> 6802ce19_522d_e5fb_e458_8826d9f6952e 1d9c6c27_a443_c5fd_35f3_e80b7125bc9f["use-toast"] f4c1b76a_47e3_9b5d_dfd6_e34964c1263a --> 1d9c6c27_a443_c5fd_35f3_e80b7125bc9f d418ad18_b947_f4e5_6e4c_01100d7a63e4["button"] f4c1b76a_47e3_9b5d_dfd6_e34964c1263a --> d418ad18_b947_f4e5_6e4c_01100d7a63e4 2f59b429_1e60_57e1_0581_cc5440e0bd30["form"] f4c1b76a_47e3_9b5d_dfd6_e34964c1263a --> 2f59b429_1e60_57e1_0581_cc5440e0bd30 0664484b_ca55_1267_592f_155e2df6f020["switch"] f4c1b76a_47e3_9b5d_dfd6_e34964c1263a --> 0664484b_ca55_1267_592f_155e2df6f020 style f4c1b76a_47e3_9b5d_dfd6_e34964c1263a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"use client"
import { zodResolver } from "@hookform/resolvers/zod"
import { useForm } from "react-hook-form"
import { z } from "zod"
import { toast } from "@/registry/default/hooks/use-toast"
import { Button } from "@/registry/default/ui/button"
import {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
} from "@/registry/default/ui/form"
import { Switch } from "@/registry/default/ui/switch"
const FormSchema = z.object({
marketing_emails: z.boolean().default(false).optional(),
security_emails: z.boolean(),
})
export default function SwitchForm() {
const form = useForm<z.infer<typeof FormSchema>>({
resolver: zodResolver(FormSchema),
defaultValues: {
security_emails: true,
},
})
function onSubmit(data: z.infer<typeof FormSchema>) {
toast({
title: "You submitted the following values:",
description: (
<pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
<code className="text-white">{JSON.stringify(data, null, 2)}</code>
</pre>
),
})
}
return (
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="w-full space-y-6">
<div>
<h3 className="mb-4 text-lg font-medium">Email Notifications</h3>
<div className="space-y-4">
<FormField
control={form.control}
name="marketing_emails"
render={({ field }) => (
<FormItem className="flex flex-row items-center justify-between rounded-lg border p-4">
<div className="space-y-0.5">
<FormLabel className="text-base">
Marketing emails
</FormLabel>
<FormDescription>
Receive emails about new products, features, and more.
</FormDescription>
</div>
<FormControl>
<Switch
checked={field.value}
onCheckedChange={field.onChange}
/>
</FormControl>
</FormItem>
)}
/>
<FormField
control={form.control}
name="security_emails"
render={({ field }) => (
<FormItem className="flex flex-row items-center justify-between rounded-lg border p-4">
<div className="space-y-0.5">
<FormLabel className="text-base">Security emails</FormLabel>
<FormDescription>
Receive emails about your account security.
</FormDescription>
</div>
<FormControl>
<Switch
checked={field.value}
onCheckedChange={field.onChange}
disabled
aria-readonly
/>
</FormControl>
</FormItem>
)}
/>
</div>
</div>
<Button type="submit">Submit</Button>
</form>
</Form>
)
}
Domain
Subdomains
Functions
Dependencies
- button
- form
- react-hook-form
- switch
- use-toast
- zod
- zod
Source
Frequently Asked Questions
What does switch-form.tsx do?
switch-form.tsx is a source file in the ui codebase, written in tsx. It belongs to the ComponentRegistry domain, ChartRegistry subdomain.
What functions are defined in switch-form.tsx?
switch-form.tsx defines 1 function(s): SwitchForm.
What does switch-form.tsx depend on?
switch-form.tsx imports 7 module(s): button, form, react-hook-form, switch, use-toast, zod, zod.
Where is switch-form.tsx in the architecture?
switch-form.tsx is located at deprecated/www/registry/default/examples/switch-form.tsx (domain: ComponentRegistry, subdomain: ChartRegistry, directory: deprecated/www/registry/default/examples).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free