Skip to content

Forgot password card ​

Asks for an email address to send a reset link, with a status message and a way back to sign in.

Installation ​

bash
npx bootcn add forgot-password-card
bash
pnpm dlx bootcn add forgot-password-card
bash
yarn dlx bootcn add forgot-password-card
bash
bunx --bun bootcn add forgot-password-card

The CLI also installs the design tokens and these blocks and components: card, input, button. It prints the <link> and <script> tags to add to your layout.

Usage ​

After the form is submitted, render the result into the role="status" paragraph (for example "If that address has an account, a reset link is on its way."). Use the same message whether or not the address exists, so the form does not reveal who has an account.

Accessibility ​

  • The status paragraph is a live region (role="status"): text placed in it is announced without moving focus. It is hidden while empty.
  • The back link has visible text; its arrow icon is decorative.

Dependencies ​

  • Bootstrap 5.3+ CSS.
  • themes/tokens/tokens.css.
  • The card component.
  • The input component.
  • The button component.

Source ​

The exact files the CLI installs (forgot-password-card@1.0.0). View on GitHub · Report an issue

html
<section class="bootcn-forgot-password-card" aria-labelledby="bootcn-forgot-password-card-title">
  <div class="card bootcn-card">
    <header class="bootcn-card__header">
      <h2 class="bootcn-card__title" id="bootcn-forgot-password-card-title">Reset your password</h2>
      <p class="bootcn-card__description">
        Enter the email you signed up with and we will send you a reset link.
      </p>
    </header>
    <form class="bootcn-card__content bootcn-forgot-password-card__form" action="#" method="post">
      <div class="bootcn-field">
        <label for="bootcn-forgot-password-card-email" class="form-label bootcn-field__label"
          >Email</label
        >
        <input
          type="email"
          class="form-control bootcn-input"
          id="bootcn-forgot-password-card-email"
          name="email"
          autocomplete="email"
          placeholder="you@example.com"
          required
        />
      </div>
      <button type="submit" class="btn bootcn-button bootcn-button--default w-100">
        Send reset link
      </button>
      <p class="bootcn-forgot-password-card__status" role="status">
        <!-- After submitting, put the result here, e.g. "Check your inbox." -->
      </p>
    </form>
    <footer class="bootcn-card__footer bootcn-forgot-password-card__footer">
      <a class="bootcn-forgot-password-card__back" href="#sign-in">
        <svg
          class="bootcn-icon"
          width="16"
          height="16"
          viewBox="0 0 24 24"
          fill="none"
          stroke="currentColor"
          stroke-width="2"
          stroke-linecap="round"
          stroke-linejoin="round"
          aria-hidden="true"
          focusable="false"
        >
          <path d="M19 12H5" />
          <path d="m11 18-6-6 6-6" />
        </svg>
        Back to sign in
      </a>
    </footer>
  </div>
</section>
css
.bootcn-forgot-password-card {
  width: 100%;
  max-width: 24rem;
  margin-inline: auto;
}

.bootcn-forgot-password-card__form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.bootcn-forgot-password-card__form .bootcn-field {
  margin: 0;
}

.bootcn-forgot-password-card__label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.bootcn-forgot-password-card__link {
  color: var(--bs-link-color);
  font-size: 0.875rem;
  text-underline-offset: 0.2em;
}

.bootcn-forgot-password-card__footer {
  justify-content: center;
  font-size: 0.875rem;
  color: var(--bs-secondary-color);
}

.bootcn-forgot-password-card__status {
  margin: 0;
  font-size: 0.875rem;
}

.bootcn-forgot-password-card__status:empty {
  display: none;
}

.bootcn-forgot-password-card__back {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--bs-body-color);
  font-size: 0.875rem;
  text-decoration: none;
}

.bootcn-forgot-password-card__back:hover {
  text-decoration: underline;
}

Released under the MIT License. Not affiliated with Bootstrap or shadcn/ui.