# Forgot Password Form

> A password reset request card with one email field and a full width Send reset email button, composed from AuthCard, FormField and Input in React.

- Kind: Component (Auth)
- Docs: https://ui.minidev.pro/docs/forgot-password-form
- Source (registry JSON with the full file): https://ui.minidev.pro/r/forgot-password-form.json
- License: MIT. One file, yours to edit after install.

## When to use

A real <form>: Enter submits, the browser checks the email format, and `onSubmit` receives the trimmed address. For setting the new password use [`ResetPasswordForm`](https://ui.minidev.pro/docs/reset-password-form); for passwordless sign-in use [`MagicLinkForm`](https://ui.minidev.pro/docs/magic-link-form).

## Installation

### shadcn CLI (copies the source into your project)

```bash
npx shadcn@latest add @minidev/forgot-password-form
```

Writes `components/ui/forgot-password-form.tsx` plus the MiniDev files it is built from (auth-card, button, form-field, input) and installs its npm dependencies. Older CLI versions: `npx shadcn@latest add https://ui.minidev.pro/r/forgot-password-form.json`.

### npm package

```bash
npm i minidev-ui-kit
```

Add the tokens to your global stylesheet once:

```css
@import "tailwindcss";
@import "minidev-ui-kit/styles.css";
@source "../node_modules/minidev-ui-kit";
```

Next.js also needs `transpilePackages: ["minidev-ui-kit"]` in next.config.

## Import

After the shadcn install:

```tsx
import { ForgotPasswordForm } from "@/components/ui/forgot-password-form"
```

From the npm package:

```tsx
import { ForgotPasswordForm } from "minidev-ui-kit/ui/forgot-password-form"
```

## Usage

```tsx
import { ForgotPasswordForm } from "@/components/ui/forgot-password-form"

export function Example() {
  return (
    <ForgotPasswordForm />
  )
}
```

## Props

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `onSubmit` | `(email: string) => void \| Promise<void>` | - | no | Called with the email address on submit. Return a promise to show a pending state until it settles; if it rejects, the form shows "Something went wrong. Try again." |
| `title` | `React.ReactNode` | `"Forgot password"` | no | Card heading. |
| `description` | `React.ReactNode` | `"We'll email you a link to reset it."` | no | Line under the heading. |
| `className` | `string` | - | no |  |

## Examples

### With a confirmation step

The form only shows Sending… while your promise runs; swap in your own confirmation when it resolves. The same message either way hides which emails have accounts.

```tsx
const wait = (ms: number) => new Promise((r) => setTimeout(r, ms))

function ForgotPasswordFlow() {
  const [sentTo, setSentTo] = React.useState("")
  if (sentTo) {
    return (
      <AuthCard
        title="Check your inbox"
        description={"If " + sentTo + " has an account, a reset link is on its way. It expires in 1 hour."}
      >
        <Button variant="outline" className="w-full" onClick={() => setSentTo("")}>Use another email</Button>
      </AuthCard>
    )
  }
  return (
    <ForgotPasswordForm
      className="w-full"
      onSubmit={async (email) => {
        await wait(800)
        setSentTo(email)
      }}
    />
  )
}
```

### Your own wording

title and description take any node.

```tsx
<ForgotPasswordForm
  className="w-full"
  title="Reset your Lumen password"
  description="Enter the email you sign in with. The link works once."
/>
```

## Accessibility

- A real `<form>` with `type="email"`, `required` and `autoComplete="email"`, so the browser checks the address and can autofill it before `onSubmit` runs.
- While pending, the submit button is `disabled` with `aria-busy="true"` and reads "Sending…".
- If `onSubmit` rejects, the error line under the field is `role="alert"`, so screen readers announce it.

## FAQ

### How do I show a "check your inbox" message after sending?

The form has no success state; it only shows "Sending…" until your promise settles. Track it yourself: `onSubmit={async (email) => { await sendResetLink(email); setSentTo(email) }}`, then render your confirmation instead of the form. [`MagicLinkForm`](https://ui.minidev.pro/docs/magic-link-form) has this built in.

### What happens if onSubmit throws?

The pending state ends and "Something went wrong. Try again." shows under the field as `role="alert"`. It clears on the next submit. Throw only for real failures, such as a network error: to avoid revealing which emails have accounts, resolve and show the same confirmation whether or not the email exists.

### Can I use a Server Action?

Call it from `onSubmit`, which receives the trimmed email: `onSubmit={(email) => requestReset(email)}`. The form prevents the native submit, so a `formAction` on the button would not run.

## Rules for generating code

- Use semantic tokens only (bg, surface, sunken, border, fg, fg-muted, fg-subtle, ink, accent, success, warning, danger). Never raw hex or palette steps like blue-500.
- Shadows only from the set: shadow-xs, shadow-sm, shadow-raised, shadow-md, shadow-lg, shadow-overlay.
- Numbers use tabular-nums. Dark mode is the `dark` class on <html>; components never branch on theme.

## Dependencies

- Built from: [auth-card](https://ui.minidev.pro/docs/auth-card/md), [button](https://ui.minidev.pro/docs/button/md), [form-field](https://ui.minidev.pro/docs/form-field/md), [input](https://ui.minidev.pro/docs/input/md)

## Related

- [Reset Password Form](https://ui.minidev.pro/docs/reset-password-form/md): Reset password card with new password and confirm password fields and a full-width Update password button, built from AuthCard, FormField and Input in React.
- [Magic Link Form](https://ui.minidev.pro/docs/magic-link-form/md): A passwordless sign in card with an email field and a Send link button that passes the address to onSend. Built from AuthCard, FormField and Input.
- [Auth Card](https://ui.minidev.pro/docs/auth-card/md): Centered Tailwind sign in card with a title, optional description, a slot for fields and providers, and a divided footer for sign up or reset links.
- [Join Workspace](https://ui.minidev.pro/docs/join-workspace/md): A centered card for joining a team workspace with an invite code: heading, helper text, a monospace code input and a full width Join button. Tailwind styled.
- [Otp Input](https://ui.minidev.pro/docs/otp-input/md): A React one time code input where one real input powers the slots, so paste, SMS autofill and screen readers work natively. Has groups, error shake and success.
- [Sign Up Form](https://ui.minidev.pro/docs/sign-up-form/md): Create account form with GitHub and Google buttons, required name, email and password fields, a submit button and a Sign in link, all inside an AuthCard.

---

All 557 components: https://ui.minidev.pro/llms.txt (full text: https://ui.minidev.pro/llms-full.txt).
