AuthForm
neon-ui/auth-formFreeComponent
The email/password card: mode switching, providers, structured errors, and a working state — Better Auth-shaped.
Install it
npx shadcn@latest add https://ui.neon.com/r/auth-form.jsonSource
1"use client";23import type { ComponentProps, FocusEvent, FormEvent, ReactNode } from "react";4import { useEffect, useId, useRef, useState } from "react";5import { createPortal } from "react-dom";67import { Button } from "@/components/ui/button";8import { cn } from "@/lib/utils";910export type AuthMode = "sign-in" | "sign-up" | "reset";1112export type AuthFieldName = "name" | "email" | "password";1314/** Returns the failure message, or null when the value passes. */15export type AuthValidator = (value: string) => string | null;1617export interface AuthProvider {18 id: string;19 label: string;20 icon?: ReactNode;21}2223export interface AuthFormValues {24 email: string;25 password: string;26 /** Present in sign-up mode. */27 name?: string;28}2930export type AuthFormProps = Omit<ComponentProps<"form">, "onSubmit"> & {31 /** Which face the form shows. */32 mode?: AuthMode;33 /** Called with the field values once they pass validation. */34 onSubmit: (values: AuthFormValues) => void;35 /** Renders the footer swap link and enables mode switching. */36 onModeChange?: (mode: AuthMode) => void;37 /** Locks the fields and puts the action in its working state. */38 isBusy?: boolean;39 /** Structured failure message rendered above the action. */40 error?: string | null;41 /** Server-side verdicts pinned to fields (e.g. incorrect password). */42 fieldErrors?: Partial<Record<AuthFieldName, string>>;43 /**44 * Per-field validators merged over the mode defaults — return the45 * failure message, or null when the value passes. Use it to bring46 * your own password policy.47 */48 validators?: Partial<Record<AuthFieldName, AuthValidator>>;49 /** OAuth-style providers rendered under the divider. */50 providers?: AuthProvider[];51 /** Called with the provider id. */52 onProvider?: (id: string) => void;53 /** Renders the forgot link on the password row (sign-in only). */54 onForgotPassword?: () => void;55 /**56 * The email a reset link was sent to. In reset mode this flips the57 * form to its confirmation face.58 */59 resetSentTo?: string | null;60 /** Renders the "send again" link on the confirmation face. */61 onResend?: () => void;62 /** Brand mark slot above the title. */63 mark?: ReactNode;64 title?: string;65 description?: string;66 /**67 * "card" (default) draws the house surface — border, bg-card,68 * padding. "bare" renders naked for split layouts that supply69 * their own panel.70 */71 variant?: "card" | "bare";72};7374// … truncated
What it pulls in
Other registry items
Files it writes
More from neon-ui
All 77 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| ActivityFeedactivity-feed | neon-ui | Components | Free | 2 deps | |
| AgentChatagent-chat | neon-ui | Components | Free | 6 deps | |
| AnimatedWashanimated-wash | neon-ui | Components | Free | no deps · 2 files | |
| ApiKeyListapi-key-list | neon-ui | Components | Free | 2 deps | |
| AppCardapp-card | neon-ui | Components | Free | 2 deps | |
| AppCreatorapp-creator | neon-ui | Components | Free | 2 deps | |
| AutoscaleChartautoscale-chart | neon-ui | Components | Free | 1 dep | |
| Badgebadge | neon-ui | Components | Free | 2 deps |
