Snippets Animation

Bootstrap 5 Password Input with Show/Hide Toggle

A sign-in card whose password field has a show/hide eye button that sweeps a soft light beam across the input when toggled.

Bootstrap 5 No jQuery Feb 2020 2.3K views

<section class="wdw-stage">
  <div class="container" style="max-width:520px">
    <form class="wdw-card overflow-hidden" id="pwForm" novalidate>
      <div class="wdw-aurora text-center px-4 py-5">
        <span class="pw-badge mb-3"><svg width="26" height="26" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="4" y="11" width="16" height="10" rx="3"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/></svg></span>
        <h1 class="h3 fw-bold mb-1">Sign in</h1>
        <p class="mb-0 opacity-75">Welcome back. Enter your details to continue.</p>
      </div>
      <div class="p-4 p-md-5">
        <div class="mb-3">
          <label for="pwUser" class="form-label fw-semibold small">Email</label>
          <input type="email" class="form-control" id="pwUser" autocomplete="username" placeholder="[email protected]">
        </div>
        <div class="mb-4">
          <label for="pwPass" class="form-label fw-semibold small">Password</label>
          <div class="pw-field position-relative">
            <input type="password" class="form-control pe-pw" id="pwPass" autocomplete="current-password" placeholder="Enter your password" value="correct horse">
            <button type="button" class="pw-toggle" id="pwToggle" aria-label="Show password" aria-pressed="false">
              <svg class="pw-eye-open" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/></svg>
              <svg class="pw-eye-shut" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 3l18 18M10.6 6.100A9.7 9.7 0 0 1 12 6c6.5 0 10 6 10 6a17 17 0 0 1-3.2 3.900M6.6 7.700C3.8 9.5 2 12 2 12s3.5 6 10 6c1.6 0 3-.4 4.2-.9"/><path d="M9.9 10a3 3 0 0 0 4.1 4.1"/></svg>
            </button>
            <span class="pw-beam" aria-hidden="true"></span>
          </div>
          <div class="form-text">Use the eye to check what you typed.</div>
        </div>
        <button type="submit" class="btn btn-primary rounded-pill w-100">Sign in</button>
      </div>
    </form>
  </div>
</section>

Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.