SwitchForm() — ui Function Reference
Architecture documentation for the SwitchForm() function in switch-form.tsx from the ui codebase.
Entity Profile
Dependency Diagram
graph TD 114ca47d_fc85_81c3_e080_2c85832734fa["SwitchForm()"] 1f7ef716_5fef_6e89_5c84_49bf6b4d4468["switch-form.tsx"] 114ca47d_fc85_81c3_e080_2c85832734fa -->|defined in| 1f7ef716_5fef_6e89_5c84_49bf6b4d4468 style 114ca47d_fc85_81c3_e080_2c85832734fa fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
deprecated/www/registry/new-york/examples/switch-form.tsx lines 24–97
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-3 shadow-sm">
<div className="space-y-0.5">
<FormLabel>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-3 shadow-sm">
<div className="space-y-0.5">
<FormLabel>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
Source
Frequently Asked Questions
What does SwitchForm() do?
SwitchForm() is a function in the ui codebase, defined in deprecated/www/registry/new-york/examples/switch-form.tsx.
Where is SwitchForm() defined?
SwitchForm() is defined in deprecated/www/registry/new-york/examples/switch-form.tsx at line 24.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free