Home / File/ input-form.tsx — ui Source File

input-form.tsx — ui Source File

Architecture documentation for input-form.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
  afdb690d_e17f_7606_be98_ebd513a5f439["input-form.tsx"]
  3d40a3bf_c062_4304_329a_00b1b72e8523["zod"]
  afdb690d_e17f_7606_be98_ebd513a5f439 --> 3d40a3bf_c062_4304_329a_00b1b72e8523
  6d65354d_8f59_2cfc_4783_24b2eb870bc4["react-hook-form"]
  afdb690d_e17f_7606_be98_ebd513a5f439 --> 6d65354d_8f59_2cfc_4783_24b2eb870bc4
  6802ce19_522d_e5fb_e458_8826d9f6952e["zod"]
  afdb690d_e17f_7606_be98_ebd513a5f439 --> 6802ce19_522d_e5fb_e458_8826d9f6952e
  1d9c6c27_a443_c5fd_35f3_e80b7125bc9f["use-toast"]
  afdb690d_e17f_7606_be98_ebd513a5f439 --> 1d9c6c27_a443_c5fd_35f3_e80b7125bc9f
  d418ad18_b947_f4e5_6e4c_01100d7a63e4["button"]
  afdb690d_e17f_7606_be98_ebd513a5f439 --> d418ad18_b947_f4e5_6e4c_01100d7a63e4
  2f59b429_1e60_57e1_0581_cc5440e0bd30["form"]
  afdb690d_e17f_7606_be98_ebd513a5f439 --> 2f59b429_1e60_57e1_0581_cc5440e0bd30
  163b5f6f_1cd3_6d8d_5305_80eec4895f60["input"]
  afdb690d_e17f_7606_be98_ebd513a5f439 --> 163b5f6f_1cd3_6d8d_5305_80eec4895f60
  style afdb690d_e17f_7606_be98_ebd513a5f439 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,
  FormMessage,
} from "@/registry/default/ui/form"
import { Input } from "@/registry/default/ui/input"

const FormSchema = z.object({
  username: z.string().min(2, {
    message: "Username must be at least 2 characters.",
  }),
})

export default function InputForm() {
  const form = useForm<z.infer<typeof FormSchema>>({
    resolver: zodResolver(FormSchema),
    defaultValues: {
      username: "",
    },
  })

  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-2/3 space-y-6">
        <FormField
          control={form.control}
          name="username"
          render={({ field }) => (
            <FormItem>
              <FormLabel>Username</FormLabel>
              <FormControl>
                <Input placeholder="shadcn" {...field} />
              </FormControl>
              <FormDescription>
                This is your public display name.
              </FormDescription>
              <FormMessage />
            </FormItem>
          )}
        />
        <Button type="submit">Submit</Button>
      </form>
    </Form>
  )
}

Subdomains

Functions

Dependencies

  • button
  • form
  • input
  • react-hook-form
  • use-toast
  • zod
  • zod

Frequently Asked Questions

What does input-form.tsx do?
input-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 input-form.tsx?
input-form.tsx defines 1 function(s): InputForm.
What does input-form.tsx depend on?
input-form.tsx imports 7 module(s): button, form, input, react-hook-form, use-toast, zod, zod.
Where is input-form.tsx in the architecture?
input-form.tsx is located at deprecated/www/registry/default/examples/input-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