Bootstrap 5 Multi-Step Form Wizard in a Modal
A launchable payment wizard in a modal, with a numbered progress stepper, sliding step transitions, per-step validation and a final review screen.
<section class="wdw-stage">
<div class="container" style="max-width:880px">
<div class="wdw-card overflow-hidden">
<div class="row g-0">
<div class="col-md-5 wdw-aurora p-4 p-md-5 d-flex flex-column justify-content-between gap-4">
<span class="badge rounded-pill text-bg-light align-self-start">Pro plan</span>
<div>
<div class="display-5 fw-bold lh-1">$24<span class="fs-6 fw-semibold opacity-75"> / month</span></div>
<p class="small opacity-75 mt-2 mb-0">Billed monthly. Cancel anytime.</p>
</div>
</div>
<div class="col-md-7 p-4 p-md-5">
<span class="wdw-eyebrow">Checkout</span>
<h1 class="wdw-heading h2 mt-1 mb-2">Multi-step wizard modal</h1>
<p class="wdw-muted mb-4">Four short steps: account, personal details, payment and a final review.</p>
<ol class="list-unstyled d-grid gap-2 mb-4 small">
<li class="d-flex align-items-center gap-2"><span class="wdw-icon" style="width:1.75rem;height:1.75rem;border-radius:.5rem">1</span> Create your account</li>
<li class="d-flex align-items-center gap-2"><span class="wdw-icon" style="width:1.75rem;height:1.75rem;border-radius:.5rem">2</span> Add personal details</li>
<li class="d-flex align-items-center gap-2"><span class="wdw-icon" style="width:1.75rem;height:1.75rem;border-radius:.5rem">3</span> Enter payment</li>
<li class="d-flex align-items-center gap-2"><span class="wdw-icon" style="width:1.75rem;height:1.75rem;border-radius:.5rem">4</span> Review and confirm</li>
</ol>
<button type="button" class="btn btn-primary rounded-pill px-4" data-bs-toggle="modal" data-bs-target="#wzModal">Launch wizard</button>
</div>
</div>
</div>
</div>
</section>
<div class="modal fade" id="wzModal" tabindex="-1" aria-labelledby="wzTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg">
<div class="modal-content border-0 wz-content overflow-hidden"><div class="row g-0"><aside class="col-md-4 wdw-aurora p-4 d-none d-md-flex flex-column justify-content-between" aria-label="Order summary"><span class="badge rounded-pill text-bg-light align-self-start">Pro plan</span><div><div class="display-6 fw-bold lh-1">$24<span class="fs-6 fw-semibold opacity-75"> / mo</span></div><ul class="list-unstyled small opacity-75 mt-3 mb-0 d-grid gap-1"><li>Unlimited projects</li><li>Team sharing</li><li>Priority support</li></ul></div></aside><div class="col-md-8 d-flex flex-column">
<div class="modal-header border-0 pb-0 px-4 pt-4">
<h2 class="modal-title h5 fw-bold" id="wzTitle">Create your account</h2>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body px-4 pb-2">
<ol class="wz-steps list-unstyled d-flex mb-4 mt-2" aria-label="Progress"><li class="wz-step is-active" data-step="0"><span class="wz-dot" aria-hidden="true"><span class="wz-num">1</span><svg class="wz-check" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></span><span class="wz-label"><span class="d-none d-sm-block small wdw-muted">Step 1</span><span class="fw-semibold small">Account</span></span></li><li class="wz-step" data-step="1"><span class="wz-dot" aria-hidden="true"><span class="wz-num">2</span><svg class="wz-check" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></span><span class="wz-label"><span class="d-none d-sm-block small wdw-muted">Step 2</span><span class="fw-semibold small">Personal</span></span></li><li class="wz-step" data-step="2"><span class="wz-dot" aria-hidden="true"><span class="wz-num">3</span><svg class="wz-check" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></span><span class="wz-label"><span class="d-none d-sm-block small wdw-muted">Step 3</span><span class="fw-semibold small">Payment</span></span></li><li class="wz-step" data-step="3"><span class="wz-dot" aria-hidden="true"><span class="wz-num">4</span><svg class="wz-check" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></span><span class="wz-label"><span class="d-none d-sm-block small wdw-muted">Step 4</span><span class="fw-semibold small">Confirm</span></span></li></ol>
<p class="visually-hidden" id="wzStatus" role="status" aria-live="polite">Step 1 of 4</p>
<form id="wzForm" novalidate>
<div class="wz-pane is-active" data-pane="0"><div class="row g-3">
<div class="col-md-6"><div class="form-floating"><input type="text" class="form-control" id="wz-name" placeholder="Name" required autocomplete="name"><label for="wz-name">Name</label><div class="invalid-feedback">Enter your full name.</div></div></div>
<div class="col-md-6"><div class="form-floating"><input type="email" class="form-control" id="wz-email" placeholder="Email" required autocomplete="email"><label for="wz-email">Email</label><div class="invalid-feedback">Enter a valid email, like [email protected].</div></div></div>
<div class="col-md-6"><div class="form-floating"><input type="password" class="form-control" id="wz-pass" placeholder="Password" required minlength="6" autocomplete="new-password"><label for="wz-pass">Password</label><div class="invalid-feedback">Use at least 6 characters.</div></div></div>
<div class="col-md-6"><div class="form-floating"><input type="password" class="form-control" id="wz-pass2" placeholder="Repeat password" required autocomplete="new-password"><label for="wz-pass2">Repeat password</label><div class="invalid-feedback">Passwords do not match.</div></div></div>
</div></div>
<div class="wz-pane" data-pane="1"><div class="row g-3">
<div class="col-12"><div class="form-floating"><input type="text" class="form-control" id="wz-addr" placeholder="Address" required autocomplete="street-address"><label for="wz-addr">Address</label><div class="invalid-feedback">Enter your street address.</div></div></div>
<div class="col-md-6"><div class="form-floating"><input type="text" class="form-control" id="wz-city" placeholder="City" required autocomplete="address-level2"><label for="wz-city">City</label><div class="invalid-feedback">Enter your city.</div></div></div>
<div class="col-md-6"><div class="form-floating"><input type="text" class="form-control" id="wz-state" placeholder="State" required autocomplete="address-level1"><label for="wz-state">State</label><div class="invalid-feedback">Enter your state or region.</div></div></div>
<div class="col-12"><div class="form-floating"><input type="text" class="form-control" id="wz-country" placeholder="Country" required autocomplete="country-name"><label for="wz-country">Country</label><div class="invalid-feedback">Enter your country.</div></div></div>
</div></div>
<div class="wz-pane" data-pane="2"><div class="row g-3">
<div class="col-12"><div class="form-floating"><input type="text" class="form-control" id="wz-card" placeholder="Card number" required inputmode="numeric" pattern="[0-9 ]{12,19}" autocomplete="cc-number"><label for="wz-card">Card number</label><div class="invalid-feedback">Enter a 16-digit card number.</div></div></div>
<div class="col-md-6"><div class="form-floating"><input type="text" class="form-control" id="wz-holder" placeholder="Card holder name" required autocomplete="cc-name"><label for="wz-holder">Card holder name</label><div class="invalid-feedback">Enter the name on the card.</div></div></div>
<div class="col-md-3 col-6"><div class="form-floating"><input type="text" class="form-control" id="wz-cvv" placeholder="CVV" required inputmode="numeric" pattern="[0-9]{3,4}" autocomplete="cc-csc"><label for="wz-cvv">CVV</label><div class="invalid-feedback">3 or 4 digits.</div></div></div>
<div class="col-md-3 col-6"><div class="form-floating"><input type="tel" class="form-control" id="wz-mobile" placeholder="Mobile" required autocomplete="tel"><label for="wz-mobile">Mobile</label><div class="invalid-feedback">Enter a mobile number.</div></div></div>
</div></div>
<div class="wz-pane" data-pane="3">
<p class="wdw-muted mb-3">Review your details before you finish.</p>
<dl class="row mb-0 wz-summary rounded-4 bg-body-tertiary p-3 mx-0 gx-0" id="wzSummary"></dl>
</div>
<div class="wz-pane text-center py-4" data-pane="done">
<span class="wdw-icon mb-3" style="width:3.5rem;height:3.5rem"><svg width="26" height="26" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></span>
<h3 class="h5 fw-bold">You are all set</h3>
<p class="wdw-muted mb-0">Your account has been created.</p>
</div>
</form>
</div>
<div class="modal-footer border-0 px-4 pb-4 justify-content-between" id="wzFooter">
<button type="button" class="btn btn-link text-body-secondary text-decoration-none px-3 invisible" id="wzBack">Back</button>
<button type="button" class="btn btn-primary rounded-pill px-4" id="wzNext">Next <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14M13 6l6 6-6 6"/></svg></button>
</div>
</div></div>
</div>
</div>
</div>
/* 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 */
.wz-content { border-radius: 1.5rem; box-shadow: var(--wdw-shadow); }
.wz-steps { gap: .5rem; position: relative; }
.wz-step { flex: 1 1 0; display: flex; align-items: center; gap: .6rem; position: relative; min-width: 0; }
.wz-step:not(:last-child)::after { content: ""; flex: 1 1 auto; height: 2px; margin-inline: .25rem; border-radius: 2px; background: var(--bs-border-color); transition: background-color .3s; }
.wz-step.is-done:not(:last-child)::after { background: var(--bs-primary); }
.wz-dot { flex: none; width: 2.1rem; height: 2.1rem; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; font-weight: 700; font-size: .85rem; background: var(--bs-tertiary-bg); color: var(--bs-secondary-color); border: 1px solid var(--bs-border-color); transition: all .25s; }
.wz-step.is-active .wz-dot { background: var(--bs-primary); border-color: var(--bs-primary); color: #fff; box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.wz-step.is-done .wz-dot { background: var(--bs-primary-bg-subtle); border-color: var(--bs-primary-border-subtle); color: var(--bs-primary); }
[data-bs-theme="dark"] .wz-step.is-active .wz-dot { color: #0f1117; }
.wz-label { line-height: 1.15; white-space: nowrap; }
.wz-step:not(.is-active) .wz-label { color: var(--bs-secondary-color); }
@media (max-width: 575.98px) { .wz-step .wz-label { display: none; } .wz-step.is-active .wz-label { display: block; flex: none; } .wz-step.is-active { flex: 0 0 auto; } .wz-step.is-active::after { display: none; } .wz-step:not(:last-child)::after { min-width: 8px; } }
.wz-pane { display: none; }
.wz-pane.is-active { display: block; animation: wz-in .35s ease both; }
.wz-pane.is-back { animation-name: wz-in-back; }
@keyframes wz-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes wz-in-back { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }
.wz-summary dt { font-weight: 600; font-size: .85rem; color: var(--bs-secondary-color); padding: .35rem 0; }
.wz-summary dd { margin: 0; padding: .35rem 0; font-weight: 600; word-break: break-word; }
@media (prefers-reduced-motion: reduce) { .wz-pane.is-active { animation: none; } }
.wz-check { display: none; }
.wz-step.is-done .wz-check { display: block; }
.wz-step.is-done .wz-num { display: none; }
.wz-step.is-done .wz-dot { background: var(--bs-primary); border-color: var(--bs-primary); color: #fff; }
[data-bs-theme="dark"] .wz-step.is-done .wz-dot { color: #0f1117; }
(function () {
function initWizard() {
var modalEl = document.getElementById('wzModal');
if (!modalEl) return;
var panes = modalEl.querySelectorAll('.wz-pane');
var steps = modalEl.querySelectorAll('.wz-step');
var back = document.getElementById('wzBack');
var next = document.getElementById('wzNext');
var form = document.getElementById('wzForm');
var summary = document.getElementById('wzSummary');
var last = steps.length - 1;
var current = 0;
function show(index, reverse) {
current = index;
panes.forEach(function (p) {
var on = p.dataset.pane === String(index);
p.classList.toggle('is-active', on);
p.classList.toggle('is-back', on && !!reverse);
});
steps.forEach(function (s, i) {
s.classList.toggle('is-active', i === Math.min(index, last));
s.classList.toggle('is-done', i < index);
if (i === Math.min(index, last)) s.setAttribute('aria-current', 'step'); else s.removeAttribute('aria-current');
});
back.classList.toggle('invisible', index === 0 || index === 'done');
var st = document.getElementById('wzStatus');
if (st) st.textContent = index === 'done' ? 'Complete' : 'Step ' + (index + 1) + ' of ' + steps.length;
next.firstChild.textContent = index === last ? 'Finish ' : 'Next ';
var f = panes[index] && panes[index].querySelector('input');
if (f && index < last) f.focus({ preventScroll: true });
}
function valid(index) {
var pane = modalEl.querySelector('.wz-pane[data-pane="' + index + '"]');
var ok = true;
var p1 = document.getElementById('wz-pass'), p2 = document.getElementById('wz-pass2');
if (p2) p2.setCustomValidity(p1.value !== p2.value ? 'mismatch' : '');
pane.querySelectorAll('input').forEach(function (i) {
var good = i.checkValidity();
i.classList.toggle('is-invalid', !good);
if (!good) ok = false;
});
if (!ok) pane.querySelector('.is-invalid').focus();
return ok;
}
function buildSummary() {
var rows = [['Name', 'wz-name'], ['Email', 'wz-email'], ['Address', 'wz-addr'], ['City', 'wz-city'], ['Country', 'wz-country'], ['Card', 'wz-card']];
summary.innerHTML = '';
rows.forEach(function (r) {
var v = document.getElementById(r[1]).value;
if (r[1] === 'wz-card') v = '•••• ' + v.replace(/\s/g, '').slice(-4);
var dt = document.createElement('dt'); dt.className = 'col-4'; dt.textContent = r[0];
var dd = document.createElement('dd'); dd.className = 'col-8'; dd.textContent = v;
summary.appendChild(dt); summary.appendChild(dd);
});
}
next.addEventListener('click', function () {
if (current === 'done') { bootstrap.Modal.getInstance(modalEl).hide(); return; }
if (!valid(current)) return;
if (current === last) {
show('done');
steps.forEach(function (s) { s.classList.add('is-done'); s.classList.remove('is-active'); });
next.firstChild.textContent = 'Close ';
return;
}
if (current + 1 === last) buildSummary();
show(current + 1);
});
back.addEventListener('click', function () { if (current > 0) show(current - 1, true); });
form.addEventListener('input', function (e) { e.target.classList.remove('is-invalid'); });
form.addEventListener('submit', function (e) { e.preventDefault(); });
modalEl.addEventListener('hidden.bs.modal', function () {
form.reset();
form.querySelectorAll('.is-invalid').forEach(function (i) { i.classList.remove('is-invalid'); });
show(0);
});
}
initWizard();
})();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.