# Reset Password Form

> 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.

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

## When to use

Use it on the page a password reset email links to. It checks the two fields match and meet `minLength` before calling `onSubmit`; send the token and password to your server there. For the "email me a link" step use a forgot password form.

## Installation

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

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

Writes `components/ui/reset-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/reset-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 { ResetPasswordForm } from "@/components/ui/reset-password-form"
```

From the npm package:

```tsx
import { ResetPasswordForm } from "minidev-ui-kit/ui/reset-password-form"
```

## Usage

```tsx
import { ResetPasswordForm } from "@/components/ui/reset-password-form"

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

## Props

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `onSubmit` | `(password: string) => void` | - | no | Called with the new password once both fields match. |
| `minLength` | `number` | `8` | no | Minimum password length enforced by the browser. |
| `className` | `string` | - | no |  |

## Examples

### Reset and confirm

The form checks the two fields match and the browser enforces minLength; show your own result when onSubmit runs.

```tsx
function ResetFlow() {
  const [done, setDone] = React.useState(false)
  if (done) {
    return (
      <div className="mx-auto w-full max-w-sm space-y-3">
        <InlineAlert tone="success" title="Password updated">Sign in with your new password. Other devices were signed out.</InlineAlert>
        <Button variant="outline" size="sm" onClick={() => setDone(false)}>Reset again</Button>
      </div>
    )
  }
  // In a real page, read the token from the URL and send it with the password.
  return <ResetPasswordForm className="w-full" minLength={12} onSubmit={() => setDone(true)} />
}
```

### Link expired

Check the token before rendering the form, and show the next step when it is no longer valid.

```tsx
<div className="mx-auto w-full max-w-sm space-y-3">
  <InlineAlert tone="danger" title="This reset link has expired">Links work for 1 hour. Request a new one to continue.</InlineAlert>
  <Button size="sm" render={<a href="#forgot-password" />}>Send a new link</Button>
</div>
```

## Accessibility

- Both fields are `type="password"` with `autoComplete="new-password"`, so password managers offer to generate and save the new password.
- The "At least 8 characters" hint is linked to the first field with `aria-describedby`.
- A mismatch shows "Passwords do not match" as `role="alert"` on the confirm field, which also gets `aria-invalid`. Typing in that field clears it.

## FAQ

### How do I show a pending state or a server error?

There are neither: `onSubmit` is called and not awaited. Show the result outside the card, for example with an [`InlineAlert`](https://ui.minidev.pro/docs/inline-alert), or add state to the copied file.

### Which password rules does it check?

Only that the two fields match and that the browser's `minLength` (default 8) and `required` pass. Check anything stricter on the server.

## 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

- [Forgot Password Form](https://ui.minidev.pro/docs/forgot-password-form/md): 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.
- [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.
- [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.
- [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).
