form-rhf-input.tsx — ui Source File
Architecture documentation for form-rhf-input.tsx, a tsx file in the ui codebase. 8 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR cf21a8b6_02d7_77d9_ce53_9929f75a997d["form-rhf-input.tsx"] 3d40a3bf_c062_4304_329a_00b1b72e8523["zod"] cf21a8b6_02d7_77d9_ce53_9929f75a997d --> 3d40a3bf_c062_4304_329a_00b1b72e8523 6d65354d_8f59_2cfc_4783_24b2eb870bc4["react-hook-form"] cf21a8b6_02d7_77d9_ce53_9929f75a997d --> 6d65354d_8f59_2cfc_4783_24b2eb870bc4 e750d152_1191_1793_7244_99c7f9c595f4["sonner"] cf21a8b6_02d7_77d9_ce53_9929f75a997d --> e750d152_1191_1793_7244_99c7f9c595f4 6802ce19_522d_e5fb_e458_8826d9f6952e["zod"] cf21a8b6_02d7_77d9_ce53_9929f75a997d --> 6802ce19_522d_e5fb_e458_8826d9f6952e 57e86e45_ac6e_7278_be08_9092724e8401["button"] cf21a8b6_02d7_77d9_ce53_9929f75a997d --> 57e86e45_ac6e_7278_be08_9092724e8401 c6d6139d_ea69_3d79_5004_68419bae2ac0["card"] cf21a8b6_02d7_77d9_ce53_9929f75a997d --> c6d6139d_ea69_3d79_5004_68419bae2ac0 169af77a_46c3_8fec_4801_f34a0f1a3471["field"] cf21a8b6_02d7_77d9_ce53_9929f75a997d --> 169af77a_46c3_8fec_4801_f34a0f1a3471 80cf663d_a411_487c_d69e_ac9d405cd2ec["input"] cf21a8b6_02d7_77d9_ce53_9929f75a997d --> 80cf663d_a411_487c_d69e_ac9d405cd2ec style cf21a8b6_02d7_77d9_ce53_9929f75a997d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"use client"
import { zodResolver } from "@hookform/resolvers/zod"
import { Controller, useForm } from "react-hook-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,
FieldDescription,
FieldError,
FieldGroup,
FieldLabel,
} from "@/registry/new-york-v4/ui/field"
import { Input } from "@/registry/new-york-v4/ui/input"
const formSchema = z.object({
username: z
.string()
.min(3, "Username must be at least 3 characters.")
.max(10, "Username must be at most 10 characters.")
.regex(
/^[a-zA-Z0-9_]+$/,
"Username can only contain letters, numbers, and underscores."
),
})
export default function FormRhfInput() {
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
username: "",
},
})
function onSubmit(data: z.infer<typeof formSchema>) {
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(data, 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">
<CardHeader>
<CardTitle>Profile Settings</CardTitle>
<CardDescription>
Update your profile information below.
</CardDescription>
</CardHeader>
<CardContent>
<form id="form-rhf-input" onSubmit={form.handleSubmit(onSubmit)}>
<FieldGroup>
<Controller
name="username"
control={form.control}
render={({ field, fieldState }) => (
<Field data-invalid={fieldState.invalid}>
<FieldLabel htmlFor="form-rhf-input-username">
Username
</FieldLabel>
<Input
{...field}
id="form-rhf-input-username"
aria-invalid={fieldState.invalid}
placeholder="shadcn"
autoComplete="username"
/>
<FieldDescription>
This is your public display name. Must be between 3 and 10
characters. Must only contain letters, numbers, and
underscores.
</FieldDescription>
{fieldState.invalid && (
<FieldError errors={[fieldState.error]} />
)}
</Field>
)}
/>
</FieldGroup>
</form>
</CardContent>
<CardFooter>
<Field orientation="horizontal">
<Button type="button" variant="outline" onClick={() => form.reset()}>
Reset
</Button>
<Button type="submit" form="form-rhf-input">
Save
</Button>
</Field>
</CardFooter>
</Card>
)
}
Domain
Subdomains
Functions
Dependencies
- button
- card
- field
- input
- react-hook-form
- sonner
- zod
- zod
Source
Frequently Asked Questions
What does form-rhf-input.tsx do?
form-rhf-input.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-rhf-input.tsx?
form-rhf-input.tsx defines 1 function(s): FormRhfInput.
What does form-rhf-input.tsx depend on?
form-rhf-input.tsx imports 8 module(s): button, card, field, input, react-hook-form, sonner, zod, zod.
Where is form-rhf-input.tsx in the architecture?
form-rhf-input.tsx is located at apps/v4/registry/new-york-v4/examples/form-rhf-input.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