Home / File/ form-tanstack-switch.tsx — ui Source File

form-tanstack-switch.tsx — ui Source File

Architecture documentation for form-tanstack-switch.tsx, a tsx file in the ui codebase. 7 imports, 0 dependents.

File tsx ComponentRegistry ChartRegistry 7 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  9f40313d_e5b8_002a_e78a_1ace7381f3a4["form-tanstack-switch.tsx"]
  32ce9c09_437f_bced_67c5_ff04d8757a76["react-form"]
  9f40313d_e5b8_002a_e78a_1ace7381f3a4 --> 32ce9c09_437f_bced_67c5_ff04d8757a76
  e750d152_1191_1793_7244_99c7f9c595f4["sonner"]
  9f40313d_e5b8_002a_e78a_1ace7381f3a4 --> e750d152_1191_1793_7244_99c7f9c595f4
  6802ce19_522d_e5fb_e458_8826d9f6952e["zod"]
  9f40313d_e5b8_002a_e78a_1ace7381f3a4 --> 6802ce19_522d_e5fb_e458_8826d9f6952e
  57e86e45_ac6e_7278_be08_9092724e8401["button"]
  9f40313d_e5b8_002a_e78a_1ace7381f3a4 --> 57e86e45_ac6e_7278_be08_9092724e8401
  c6d6139d_ea69_3d79_5004_68419bae2ac0["card"]
  9f40313d_e5b8_002a_e78a_1ace7381f3a4 --> c6d6139d_ea69_3d79_5004_68419bae2ac0
  169af77a_46c3_8fec_4801_f34a0f1a3471["field"]
  9f40313d_e5b8_002a_e78a_1ace7381f3a4 --> 169af77a_46c3_8fec_4801_f34a0f1a3471
  38ebb3c2_9638_6c9d_8ced_a16ec1ff06c9["switch"]
  9f40313d_e5b8_002a_e78a_1ace7381f3a4 --> 38ebb3c2_9638_6c9d_8ced_a16ec1ff06c9
  style 9f40313d_e5b8_002a_e78a_1ace7381f3a4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/* eslint-disable react/no-children-prop */
"use client"

import { useForm } from "@tanstack/react-form"
import { toast } from "sonner"
import * as z from "zod"

import { Button } from "@/registry/new-york-v4/ui/button"
import {
  Card,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
} from "@/registry/new-york-v4/ui/card"
import {
  Field,
  FieldContent,
  FieldDescription,
  FieldError,
  FieldGroup,
  FieldLabel,
} from "@/registry/new-york-v4/ui/field"
import { Switch } from "@/registry/new-york-v4/ui/switch"

const formSchema = z.object({
  twoFactor: z.boolean().refine((val) => val === true, {
    message: "It is highly recommended to enable two-factor authentication.",
  }),
})

export default function FormTanstackSwitch() {
  const form = useForm({
    defaultValues: {
      twoFactor: false,
    },
    validators: {
      onSubmit: formSchema,
    },
    onSubmit: async ({ value }) => {
      toast("You submitted the following values:", {
        description: (
          <pre className="bg-code text-code-foreground mt-2 w-[320px] overflow-x-auto rounded-md p-4">
            <code>{JSON.stringify(value, null, 2)}</code>
          </pre>
        ),
        position: "bottom-right",
        classNames: {
          content: "flex flex-col gap-2",
        },
        style: {
          "--border-radius": "calc(var(--radius)  + 4px)",
        } as React.CSSProperties,
      })
    },
  })

  return (
    <Card className="w-full sm:max-w-md">
// ... (62 more lines)

Subdomains

Dependencies

  • button
  • card
  • field
  • react-form
  • sonner
  • switch
  • zod

Frequently Asked Questions

What does form-tanstack-switch.tsx do?
form-tanstack-switch.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 form-tanstack-switch.tsx?
form-tanstack-switch.tsx defines 1 function(s): FormTanstackSwitch.
What does form-tanstack-switch.tsx depend on?
form-tanstack-switch.tsx imports 7 module(s): button, card, field, react-form, sonner, switch, zod.
Where is form-tanstack-switch.tsx in the architecture?
form-tanstack-switch.tsx is located at apps/v4/registry/new-york-v4/examples/form-tanstack-switch.tsx (domain: ComponentRegistry, subdomain: ChartRegistry, directory: apps/v4/registry/new-york-v4/examples).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free