Bootstrap 5 Login Form in Modal
A sign-in modal with floating-label email and password fields, a show/hide password toggle, remember-me and inline validation.
<section class="wdw-stage">
<div class="container text-center" style="max-width:640px">
<span class="wdw-eyebrow">Account</span>
<h2 class="wdw-heading display-6 mt-1 mb-3">Welcome back</h2>
<button type="button" class="btn btn-primary btn-lg rounded-pill px-5" data-bs-toggle="modal" data-bs-target="#loginModal" data-wdw-autoopen>Log in</button>
</div>
<div class="modal fade" id="loginModal" tabindex="-1" aria-labelledby="loginTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg">
<div class="modal-content lg-modal border-0 overflow-hidden">
<div class="row g-0">
<div class="col-md-5 wdw-aurora p-4 p-lg-5 d-flex flex-column justify-content-center">
<span class="wdw-eyebrow text-white opacity-75">Register now for free</span>
<h3 class="wdw-heading h3 mt-1 mb-4 text-white">Join and shop smarter</h3>
<ul class="list-unstyled d-flex flex-column gap-3 mb-4"><li class="d-flex gap-3 align-items-start"><span class="wdw-icon lg-ben" aria-hidden="true"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M9 11l3 3L22 4M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"/></svg></span><div><div class="fw-semibold">See your orders</div><div class="small opacity-75">Track every purchase and delivery in one place.</div></div></li><li class="d-flex gap-3 align-items-start"><span class="wdw-icon lg-ben" aria-hidden="true"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7l-1-1.1a5.5 5.5 0 0 0-7.8 7.8l1 1.1L12 21l7.8-7.5 1-1.1a5.5 5.5 0 0 0 0-7.8z"/></svg></span><div><div class="fw-semibold">Save favourites</div><div class="small opacity-75">Build a wishlist and come back to it any time.</div></div></li><li class="d-flex gap-3 align-items-start"><span class="wdw-icon lg-ben" aria-hidden="true"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M13 2L3 14h9l-1 8 10-12h-9z"/></svg></span><div><div class="fw-semibold">Fast checkout</div><div class="small opacity-75">Saved details mean you pay in a couple of clicks.</div></div></li><li class="d-flex gap-3 align-items-start"><span class="wdw-icon lg-ben" aria-hidden="true"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg></span><div><div class="fw-semibold">Member offers</div><div class="small opacity-75">Early access to sales and members-only prices.</div></div></li></ul>
<button type="button" class="btn btn-light rounded-pill align-self-start px-4">Create account</button>
</div>
<div class="col-md-7 position-relative">
<button type="button" class="btn-close position-absolute top-0 end-0 m-3" data-bs-dismiss="modal" aria-label="Close"></button>
<div class="p-4 p-lg-5">
<h3 class="modal-title h4 wdw-heading mb-1" id="loginTitle">Log in to your account</h3>
<p class="wdw-muted mb-4">Welcome back. Enter your details below.</p>
<form id="loginForm" novalidate>
<div class="form-floating mb-3">
<input type="email" class="form-control" id="lgEmail" placeholder="Email" autocomplete="email" aria-describedby="lgEmailErr" required>
<label for="lgEmail">Email address</label>
<div class="invalid-feedback" id="lgEmailErr">Enter a valid email address.</div>
</div>
<div class="form-floating mb-3 position-relative">
<input type="password" class="form-control pe-5" id="lgPass" placeholder="Password" autocomplete="current-password" minlength="6" aria-describedby="lgPassErr" required>
<label for="lgPass">Password</label>
<button type="button" class="btn btn-sm btn-link position-absolute top-0 end-0 mt-2 me-2 p-0 lg-eye" id="lgToggle" aria-controls="lgPass" aria-pressed="false" aria-label="Show password">
<svg 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="M1 12s4-8 11-8 11 8 11 8-4 8-11 8S1 12 1 12z"/><circle cx="12" cy="12" r="3"/></svg>
</button>
<div class="invalid-feedback" id="lgPassErr">Password must be at least 6 characters.</div>
</div>
<div class="d-flex justify-content-between align-items-center mb-4">
<div class="form-check mb-0">
<input class="form-check-input" type="checkbox" id="lgRemember">
<label class="form-check-label" for="lgRemember">Remember me</label>
</div>
<a href="#" class="small link-primary text-decoration-none fw-semibold">Forgot password?</a>
</div>
<button type="submit" class="btn btn-primary rounded-pill w-100">Log in</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
/* Web Designer Wall library style — shared base for every Bootstrap 5 snippet.
Indigo accent, Plus Jakarta Sans, soft cards, pill buttons. Works in light and dark. */
@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap");
:root,
[data-bs-theme="light"] {
--wdw-font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
--bs-body-font-family: var(--wdw-font);
--bs-primary: #4f46e5;
--bs-primary-rgb: 79, 70, 229;
--bs-primary-text-emphasis: #3730a3;
--bs-primary-bg-subtle: #eef2ff;
--bs-primary-border-subtle: #c7d2fe;
--bs-link-color: #4f46e5;
--bs-link-color-rgb: 79, 70, 229;
--bs-link-hover-color: #4338ca;
--bs-link-hover-color-rgb: 67, 56, 202;
--bs-focus-ring-color: rgba(79, 70, 229, 0.25);
--bs-border-radius: 0.75rem;
--bs-border-radius-lg: 1rem;
--bs-border-radius-xl: 1.25rem;
--wdw-radius-card: 1.25rem;
--wdw-shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 16px 40px -16px rgba(16, 24, 40, 0.22);
--wdw-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 12px -4px rgba(16, 24, 40, 0.12);
--wdw-stage: #f5f6fb;
}
[data-bs-theme="dark"] {
--bs-primary: #818cf8;
--bs-primary-rgb: 129, 140, 248;
--bs-primary-text-emphasis: #c7d2fe;
--bs-primary-bg-subtle: rgba(129, 140, 248, 0.14);
--bs-primary-border-subtle: rgba(129, 140, 248, 0.35);
--bs-link-color: #a5b4fc;
--bs-link-color-rgb: 165, 180, 252;
--bs-link-hover-color: #c7d2fe;
--bs-link-hover-color-rgb: 199, 210, 254;
--bs-focus-ring-color: rgba(129, 140, 248, 0.35);
--wdw-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px -16px rgba(0, 0, 0, 0.7);
--wdw-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px -4px rgba(0, 0, 0, 0.5);
--wdw-stage: #0f1117;
}
body { font-family: var(--wdw-font); -webkit-font-smoothing: antialiased; }
/* Bootstrap compiles its blue into these components; point them at the accent. */
.btn-primary {
--bs-btn-bg: var(--bs-primary); --bs-btn-border-color: var(--bs-primary);
--bs-btn-hover-bg: #4338ca; --bs-btn-hover-border-color: #4338ca;
--bs-btn-active-bg: #3730a3; --bs-btn-active-border-color: #3730a3;
--bs-btn-disabled-bg: var(--bs-primary); --bs-btn-disabled-border-color: var(--bs-primary);
--bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}
[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #0f1117; --bs-btn-hover-bg: #a5b4fc; --bs-btn-hover-border-color: #a5b4fc; --bs-btn-hover-color: #0f1117; --bs-btn-active-color: #0f1117; }
.btn-outline-primary {
--bs-btn-color: var(--bs-primary); --bs-btn-border-color: var(--bs-primary);
--bs-btn-hover-bg: var(--bs-primary); --bs-btn-hover-border-color: var(--bs-primary);
--bs-btn-active-bg: var(--bs-primary); --bs-btn-active-border-color: var(--bs-primary);
--bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}
.btn { --bs-btn-font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; }
.btn-sm { min-height: 36px; }
.form-control, .form-select { min-height: 44px; border-radius: .75rem; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: rgba(var(--bs-primary-rgb), .6); box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.form-check-input:checked { background-color: var(--bs-primary); border-color: var(--bs-primary); }
.nav-pills { --bs-nav-pills-link-active-bg: var(--bs-primary); }
.nav { --bs-nav-link-color: var(--bs-secondary-color); --bs-nav-link-hover-color: var(--bs-emphasis-color); }
.pagination { --bs-pagination-active-bg: var(--bs-primary); --bs-pagination-active-border-color: var(--bs-primary); --bs-pagination-color: var(--bs-body-color); --bs-pagination-focus-box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.progress, .progress-stacked { --bs-progress-bar-bg: var(--bs-primary); }
.list-group { --bs-list-group-active-bg: var(--bs-primary); --bs-list-group-active-border-color: var(--bs-primary); }
.dropdown-menu { --bs-dropdown-link-active-bg: var(--bs-primary); border-radius: .875rem; box-shadow: var(--wdw-shadow-sm); }
.accordion { --bs-accordion-active-bg: var(--bs-primary-bg-subtle); --bs-accordion-active-color: var(--bs-primary-text-emphasis); --bs-accordion-btn-focus-box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.badge { font-weight: 600; }
/* Library building blocks — use these instead of re-inventing them per snippet. */
.wdw-stage { min-height: 100vh; display: flex; align-items: center; background: var(--wdw-stage); padding-block: 3rem; }
.wdw-card { background: var(--bs-body-bg); border: 1px solid var(--bs-border-color-translucent); border-radius: var(--wdw-radius-card); box-shadow: var(--wdw-shadow); }
.wdw-card-sm { background: var(--bs-body-bg); border: 1px solid var(--bs-border-color-translucent); border-radius: 1rem; box-shadow: var(--wdw-shadow-sm); }
.wdw-aurora { position: relative; color: #fff; background: radial-gradient(60% 55% at 100% 0, #818cf8 0, transparent 70%), radial-gradient(65% 60% at 0 100%, #ec4899 0, transparent 65%), #1e1b4b; }
.wdw-eyebrow { display: inline-block; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--bs-primary); }
.wdw-heading { font-weight: 800; letter-spacing: -.02em; color: var(--bs-emphasis-color); }
.wdw-muted { color: var(--bs-secondary-color); }
.wdw-icon { width: 2.75rem; height: 2.75rem; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: .875rem; background: var(--bs-primary-bg-subtle); color: var(--bs-primary); }
/* Component */
.modal-backdrop.show{--bs-backdrop-opacity:.55}
.lg-modal{border-radius:var(--wdw-radius-card);box-shadow:var(--wdw-shadow)}
.lg-ben{width:2.25rem;height:2.25rem;border-radius:.75rem;background:rgba(255,255,255,.16);color:#fff}
.lg-eye{width:36px;height:36px;min-height:36px;color:var(--bs-secondary-color);display:inline-flex;align-items:center;justify-content:center}
.lg-eye[aria-pressed=true]{color:var(--bs-primary)}
(function initLoginModal() {
var form = document.getElementById('loginForm');
var modalEl = document.getElementById('loginModal');
if (!form || !modalEl) return;
var pass = document.getElementById('lgPass');
var toggle = document.getElementById('lgToggle');
toggle.addEventListener('click', function () {
var show = pass.type === 'password';
pass.type = show ? 'text' : 'password';
toggle.setAttribute('aria-pressed', String(show));
});
form.addEventListener('submit', function (e) {
e.preventDefault();
form.querySelectorAll('input[required]').forEach(function (f) {
f.classList.toggle('is-invalid', !f.checkValidity());
});
if (form.checkValidity()) bootstrap.Modal.getInstance(modalEl).hide();
});
modalEl.addEventListener('shown.bs.modal', function () {
document.getElementById('lgEmail').focus({ preventScroll: true });
});
/* data-wdw-autoopen on the trigger opens the modal on load (used for the preview image); remove it for production */
var auto = document.querySelector('[data-wdw-autoopen]');
if (auto) bootstrap.Modal.getOrCreateInstance(modalEl).show();
})();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.