Snippets Form

Bootstrap 5 Login and Registration Form with Switch

A combined login and registration card with a pill switch that swaps the fields and copy, inline validation and social sign-in buttons.

Bootstrap 5 No jQuery Nov 2020 6.1K views

<section class="wdw-stage">
  <div class="container" style="max-width:940px">
    <div class="wdw-card overflow-hidden">
      <div class="row g-0">
        <aside class="col-lg-5 wdw-aurora ac-side d-none d-lg-flex flex-column justify-content-between p-5">
          <span class="wdw-icon ac-side-icon"><svg width="22" height="22" 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="2"/><path d="M8 11V7a4 4 0 0 1 8 0v4"/></svg></span>
          <div>
            <h2 class="h3 fw-bold mb-3">Everything in one place.</h2>
            <ul class="list-unstyled small mb-0 d-grid gap-2 ac-perks">
              <li class="d-flex gap-2"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12l5 5L20 7"/></svg>Free 14-day trial, no card</li>
              <li class="d-flex gap-2"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12l5 5L20 7"/></svg>Sync across all your devices</li>
              <li class="d-flex gap-2"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12l5 5L20 7"/></svg>Cancel any time</li>
            </ul>
          </div>
        </aside>
        <div class="col-lg-7 p-4 p-md-5">
          <div id="ac-head" aria-live="polite" class="mb-4">
            <h2 class="wdw-heading h3 mb-1" id="ac-title">Welcome back</h2>
            <p class="wdw-muted mb-0" id="ac-sub">Log in to continue to your dashboard.</p>
          </div>
          <div class="ac-switch d-flex rounded-pill p-1 mb-4" role="group" aria-label="Login or register">
            <button type="button" class="btn rounded-pill flex-fill active" data-ac-mode="login" aria-pressed="true">Log in</button>
            <button type="button" class="btn rounded-pill flex-fill" data-ac-mode="register" aria-pressed="false">Register</button>
          </div>
          <form id="ac-form" novalidate>
            <div id="ac-panel">
              <div class="form-floating mb-3 ac-reg d-none">
                <input class="form-control" id="ac-name" placeholder="Full name" autocomplete="name" disabled required>
                <label for="ac-name">Full name</label>
                <div class="invalid-feedback">Enter your name.</div>
              </div>
              <div class="form-floating mb-3">
                <input type="email" class="form-control" id="ac-email" placeholder="Email" autocomplete="email" required>
                <label for="ac-email">Email address</label>
                <div class="invalid-feedback">Enter a valid email address.</div>
              </div>
              <div class="form-floating mb-3">
                <input type="password" class="form-control" id="ac-pass" placeholder="Password" autocomplete="current-password" minlength="6" required>
                <label for="ac-pass">Password</label>
                <div class="invalid-feedback">Use at least 6 characters.</div>
              </div>
              <div class="d-flex justify-content-between align-items-center mb-4 ac-log">
                <div class="form-check mb-0"><input class="form-check-input" type="checkbox" id="ac-rem"><label class="form-check-label" for="ac-rem">Remember me</label></div>
                <a href="#" class="small fw-semibold link-underline-opacity-0">Forgot password?</a>
              </div>
              <div class="form-check mb-4 ac-reg d-none">
                <input class="form-check-input" type="checkbox" id="ac-terms" disabled required>
                <label class="form-check-label" for="ac-terms">I accept the terms of service</label>
              </div>
            </div>
            <button type="submit" class="btn btn-primary rounded-pill w-100" id="ac-submit">Log in</button>
            <div class="alert alert-success d-none mt-3 mb-0 py-2" id="ac-ok" role="status"></div>
          </form>
          <div class="d-flex align-items-center gap-3 my-4 wdw-muted small"><hr class="flex-grow-1 m-0"><span>or continue with</span><hr class="flex-grow-1 m-0"></div>
          <div class="row g-2">
            <div class="col-6"><button type="button" class="btn btn-outline-secondary rounded-pill w-100">
              <svg width="18" height="18" viewBox="0 0 24 24" aria-hidden="true"><path fill="#4285F4" d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.27-4.74 3.27-8.1z"/><path fill="#34A853" d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84A11 11 0 0 0 12 23z"/><path fill="#FBBC05" d="M5.84 14.1a6.6 6.6 0 0 1 0-4.2V7.06H2.18a11 11 0 0 0 0 9.88l3.66-2.84z"/><path fill="#EA4335" d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1A11 11 0 0 0 2.18 7.06l3.66 2.84C6.71 7.31 9.14 5.38 12 5.38z"/></svg>Google</button></div>
            <div class="col-6"><button type="button" class="btn btn-outline-secondary rounded-pill w-100">
              <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 .5A11.5 11.5 0 0 0 .5 12c0 5.08 3.29 9.39 7.86 10.91.58.1.79-.25.79-.56v-2c-3.2.7-3.87-1.37-3.87-1.37-.52-1.33-1.28-1.69-1.28-1.69-1.04-.71.08-.7.08-.7 1.15.08 1.76 1.18 1.76 1.18 1.03 1.76 2.69 1.25 3.35.96.1-.74.4-1.25.73-1.54-2.55-.29-5.24-1.28-5.24-5.68 0-1.26.45-2.28 1.18-3.09-.12-.29-.51-1.46.11-3.05 0 0 .97-.31 3.17 1.18a11 11 0 0 1 5.77 0c2.2-1.49 3.17-1.18 3.17-1.18.63 1.59.23 2.76.11 3.05.74.81 1.18 1.83 1.18 3.09 0 4.41-2.69 5.38-5.25 5.67.41.36.78 1.06.78 2.14v3.17c0 .31.21.67.8.56A11.5 11.5 0 0 0 23.5 12 11.5 11.5 0 0 0 12 .5z"/></svg>GitHub</button></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>

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

Free to use in personal and commercial projects under the MIT license.