FormRhfPassword() — ui Function Reference
Architecture documentation for the FormRhfPassword() function in form-rhf-password.tsx from the ui codebase.
Entity Profile
Dependency Diagram
graph TD deed02a4_94be_c423_fa86_fdc8c549711c["FormRhfPassword()"] ca516639_08f4_c750_43a7_99fcf022fda4["form-rhf-password.tsx"] deed02a4_94be_c423_fa86_fdc8c549711c -->|defined in| ca516639_08f4_c750_43a7_99fcf022fda4 style deed02a4_94be_c423_fa86_fdc8c549711c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
apps/v4/registry/new-york-v4/examples/form-rhf-password.tsx lines 78–224
export default function FormRhfPassword() {
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
password: "",
},
})
const password = useWatch({
control: form.control,
name: "password",
})
// Calculate password strength.
const metRequirements = passwordRequirements.filter((req) =>
req.test(password || "")
)
const strengthPercentage =
(metRequirements.length / passwordRequirements.length) * 100
// Determine strength level and color.
const getStrengthColor = () => {
if (strengthPercentage === 0) return "bg-neutral-200"
if (strengthPercentage <= 40) return "bg-red-500"
if (strengthPercentage <= 80) return "bg-yellow-500"
return "bg-green-500"
}
const allRequirementsMet =
metRequirements.length === passwordRequirements.length
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 className="border-b">
<CardTitle>Create Password</CardTitle>
<CardDescription>
Choose a strong password to secure your account.
</CardDescription>
</CardHeader>
<CardContent>
<form id="form-rhf-password" onSubmit={form.handleSubmit(onSubmit)}>
<FieldGroup>
<Controller
name="password"
control={form.control}
render={({ field, fieldState }) => (
<Field data-invalid={fieldState.invalid}>
<FieldLabel htmlFor="form-rhf-password-input">
Password
</FieldLabel>
<InputGroup>
<InputGroupInput
{...field}
id="form-rhf-password-input"
type="password"
placeholder="Enter your password"
aria-invalid={fieldState.invalid}
autoComplete="new-password"
/>
<InputGroupAddon align="inline-end">
<CheckIcon
className={
allRequirementsMet
? "text-green-500"
Domain
Subdomains
Source
Frequently Asked Questions
What does FormRhfPassword() do?
FormRhfPassword() is a function in the ui codebase, defined in apps/v4/registry/new-york-v4/examples/form-rhf-password.tsx.
Where is FormRhfPassword() defined?
FormRhfPassword() is defined in apps/v4/registry/new-york-v4/examples/form-rhf-password.tsx at line 78.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free