Bootstrap 5 Multi-Step Form Wizard with Progress Bar
A four-step checkout wizard with a segmented progress bar, validation on each step and a final order summary.
<section class="wdw-stage">
<div class="container" style="max-width: 640px">
<form class="wdw-card p-4 p-md-5" id="wizard" novalidate>
<div class="d-flex justify-content-between align-items-center mb-3">
<span class="wdw-eyebrow" id="wizStep" aria-live="polite">Step 1 of 4</span>
<span class="wdw-muted small" id="wizPct">25%</span>
</div>
<ol class="wiz-steps list-unstyled d-flex mb-4" id="wizBars" aria-hidden="true">
<li class="is-current"><span class="wiz-dot">1</span><span class="wiz-lbl">Details</span></li>
<li><span class="wiz-dot">2</span><span class="wiz-lbl">Delivery</span></li>
<li><span class="wiz-dot">3</span><span class="wiz-lbl">Payment</span></li>
<li><span class="wiz-dot">4</span><span class="wiz-lbl">Confirm</span></li>
</ol>
<fieldset class="wiz-pane">
<legend class="wdw-heading h3 mb-1" tabindex="-1">Customer details</legend>
<p class="wdw-muted mb-4">Tell us who is placing the order.</p>
<div class="form-floating mb-3"><input type="text" class="form-control" id="wName" aria-describedby="wNameErr" placeholder="Name" required autocomplete="name"><label for="wName">Full name</label><div class="invalid-feedback" id="wNameErr">Enter your full name</div></div>
<div class="form-floating mb-3"><input type="email" class="form-control" id="wEmail" aria-describedby="wEmailErr" placeholder="Email" required autocomplete="email"><label for="wEmail">Email</label><div class="invalid-feedback" id="wEmailErr">Enter a valid email, like [email protected]</div></div>
<div class="form-floating mb-3"><input type="tel" class="form-control" id="wPhone" aria-describedby="wPhoneErr" placeholder="Phone" required autocomplete="tel"><label for="wPhone">Phone number</label><div class="invalid-feedback" id="wPhoneErr">Enter a phone number with 7 to 15 digits</div></div>
<div class="form-floating"><input type="text" class="form-control" id="wAddr" aria-describedby="wAddrErr" placeholder="Address" required autocomplete="street-address"><label for="wAddr">Street address</label><div class="invalid-feedback" id="wAddrErr">Enter your street address</div></div>
</fieldset>
<fieldset class="wiz-pane" hidden>
<legend class="wdw-heading h3 mb-1" tabindex="-1">Delivery</legend>
<p class="wdw-muted mb-4">Choose how fast you want it.</p>
<div class="d-grid gap-3">
<input type="radio" class="btn-check" name="ship" id="s1" value="Standard" checked><label class="wiz-opt" for="s1"><span><strong>Standard</strong><small>3 to 5 business days</small></span><span class="fw-bold">Free</span></label>
<input type="radio" class="btn-check" name="ship" id="s2" value="Express"><label class="wiz-opt" for="s2"><span><strong>Express</strong><small>1 to 2 business days</small></span><span class="fw-bold">$9</span></label>
<input type="radio" class="btn-check" name="ship" id="s3" value="Same-day"><label class="wiz-opt" for="s3"><span><strong>Same day</strong><small>Order before noon</small></span><span class="fw-bold">$19</span></label>
</div>
</fieldset>
<fieldset class="wiz-pane" hidden>
<legend class="wdw-heading h3 mb-1" tabindex="-1">Payment</legend>
<p class="wdw-muted mb-4">Demo only. Nothing is sent anywhere.</p>
<div class="form-floating mb-3"><input type="text" class="form-control" id="wCard" aria-describedby="wCardErr" placeholder="Card" inputmode="numeric" required autocomplete="cc-number"><label for="wCard">Card number</label><div class="invalid-feedback" id="wCardErr">Enter a 13 to 19 digit card number</div></div>
<div class="row g-3">
<div class="col-6"><div class="form-floating"><input type="text" class="form-control" id="wExp" aria-describedby="wExpErr" placeholder="MM/YY" required autocomplete="cc-exp"><label for="wExp">Expiry (MM/YY)</label><div class="invalid-feedback" id="wExpErr">Use MM/YY with a future date</div></div></div>
<div class="col-6"><div class="form-floating"><input type="text" class="form-control" id="wCvc" aria-describedby="wCvcErr" placeholder="CVC" inputmode="numeric" required autocomplete="cc-csc"><label for="wCvc">CVC</label><div class="invalid-feedback" id="wCvcErr">Enter the 3 or 4 digit code</div></div></div>
</div>
</fieldset>
<fieldset class="wiz-pane" hidden>
<legend class="wdw-heading h3 mb-1" tabindex="-1">Confirm order</legend>
<p class="wdw-muted mb-4">Check everything looks right.</p>
<dl class="row mb-0 g-2" id="wSummary"></dl>
<div class="alert alert-success d-none mt-4 mb-0" id="wDone" role="status">Order confirmed. A receipt is on its way to your inbox.</div>
</fieldset>
<div class="wiz-total d-flex justify-content-between align-items-center mt-4 p-3 rounded-3 bg-body-tertiary">
<span class="text-body-secondary small">Order total <span class="d-none d-sm-inline">(2 items)</span></span>
<strong class="text-body-emphasis" id="wTotal">$48.00</strong>
</div>
<div class="d-flex justify-content-between gap-2 mt-3">
<button type="button" class="btn btn-outline-secondary rounded-pill px-4 invisible" id="wBack">Back</button>
<button type="button" class="btn btn-primary rounded-pill px-4" id="wNext">Next
<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14M13 6l6 6-6 6"/></svg></button>
</div>
<p class="wdw-muted small text-center mt-3 mb-0 d-flex justify-content-center align-items-center gap-2"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" 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>Secure checkout. Free returns within 30 days.</p>
</form>
</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 */
.wiz-steps { position: relative; gap: 0; padding: 0; }
.wiz-steps li { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .4rem; position: relative; color: var(--bs-secondary-color); font-size: .8125rem; font-weight: 600; }
.wiz-steps li::before { content: ""; position: absolute; top: 15px; right: 50%; width: 100%; height: 3px; border-radius: 3px; background: var(--bs-border-color); z-index: 0; transition: background .3s; }
.wiz-steps li:first-child::before { display: none; }
.wiz-steps li.is-done::before, .wiz-steps li.is-current::before { background: var(--bs-primary); }
.wiz-dot { position: relative; z-index: 1; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--bs-body-bg); border: 2px solid var(--bs-border-color); font-size: .8125rem; color: var(--bs-secondary-color); transition: all .3s; }
.wiz-steps li.is-current .wiz-dot { border-color: var(--bs-primary); color: var(--bs-primary); box-shadow: 0 0 0 4px var(--bs-focus-ring-color); }
.wiz-steps li.is-current { color: var(--bs-emphasis-color); }
.wiz-steps li.is-done .wiz-dot { background: var(--bs-primary); border-color: var(--bs-primary); color: var(--bs-body-bg); font-size: 0; }
.wiz-steps li.is-done .wiz-dot::after { content: ""; width: 12px; height: 7px; border-left: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor; transform: rotate(-45deg) translate(1px,-1px); }
.wiz-pane legend:focus { outline: 0; }
.wiz-pane { border: 0; padding: 0; min-width: 0; }
.wiz-pane legend { float: none; width: auto; padding: 0; }
.wiz-pane:not([hidden]) { animation: wizIn .3s ease; }
@keyframes wizIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
.wiz-opt { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.25rem; border: 1px solid var(--bs-border-color); border-radius: 1rem; cursor: pointer; background: var(--bs-body-bg); color: var(--bs-body-color); transition: border-color .15s, background .15s; }
.wiz-opt strong { display: block; color: var(--bs-emphasis-color); }
.wiz-opt small { color: var(--bs-secondary-color); }
.wiz-opt:hover { border-color: var(--bs-primary-border-subtle); }
.btn-check:checked + .wiz-opt { border-color: var(--bs-primary); background: var(--bs-primary-bg-subtle); box-shadow: 0 0 0 1px var(--bs-primary); }
.btn-check:focus-visible + .wiz-opt { box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
#wSummary dt { color: var(--bs-secondary-color); font-weight: 500; }
#wSummary dd { color: var(--bs-emphasis-color); font-weight: 600; margin: 0; text-align: end; }
@media (prefers-reduced-motion: reduce) { .wiz-pane:not([hidden]) { animation: none; } }
(function () {
function initWizard() {
var form = document.getElementById('wizard');
if (!form) return;
var panes = Array.prototype.slice.call(form.querySelectorAll('.wiz-pane'));
var steps = form.querySelectorAll('.wiz-steps li');
var back = document.getElementById('wBack'), next = document.getElementById('wNext');
var label = document.getElementById('wizStep'), pct = document.getElementById('wizPct');
var totalEl = document.getElementById('wTotal');
var prices = { Standard: 0, Express: 9, 'Same-day': 19 };
var i = 0, finished = false;
function expiryOk(v) {
var m = /^(\d{2})\/(\d{2})$/.exec(v);
if (!m) return false;
var mo = +m[1], yr = 2000 + +m[2], now = new Date();
return mo >= 1 && mo <= 12 && (yr > now.getFullYear() || (yr === now.getFullYear() && mo >= now.getMonth() + 1));
}
function isBad(f) {
var v = f.value.trim();
if (!v) return true;
if (f.id === 'wEmail') return !/^\S+@\S+\.\S+$/.test(v);
if (f.id === 'wPhone') return !/^\+?[\d\s().-]{7,20}$/.test(v) || v.replace(/\D/g, '').length < 7 || v.replace(/\D/g, '').length > 15;
if (f.id === 'wCard') { var d = v.replace(/\s/g, ''); return !/^\d{13,19}$/.test(d); }
if (f.id === 'wExp') return !expiryOk(v);
if (f.id === 'wCvc') return !/^\d{3,4}$/.test(v);
return false;
}
function validPane() {
var ok = true;
panes[i].querySelectorAll('input[required]').forEach(function (f) {
var bad = isBad(f);
f.classList.toggle('is-invalid', bad);
if (bad) f.setAttribute('aria-invalid', 'true'); else f.removeAttribute('aria-invalid');
if (bad) ok = false;
});
var firstBad = panes[i].querySelector('.is-invalid');
if (firstBad) firstBad.focus();
return ok;
}
function summary() {
var ship = form.querySelector('input[name="ship"]:checked').value;
var rows = [['Name', 'wName'], ['Email', 'wEmail'], ['Phone', 'wPhone'], ['Address', 'wAddr']];
var dl = document.getElementById('wSummary');
dl.innerHTML = rows.map(function () { return '<dt class="col-5"></dt><dd class="col-7"></dd>'; }).join('') + '<dt class="col-5"></dt><dd class="col-7"></dd><dt class="col-5"></dt><dd class="col-7"></dd>';
var dts = dl.querySelectorAll('dt'), dds = dl.querySelectorAll('dd');
rows.forEach(function (r, k) { dts[k].textContent = r[0]; dds[k].textContent = document.getElementById(r[1]).value; });
dts[4].textContent = 'Delivery'; dds[4].textContent = ship;
dts[5].textContent = 'Card';
var card = document.getElementById('wCard').value.replace(/\s/g, '');
dds[5].textContent = card ? 'Ending ' + card.slice(-4) : '';
}
function updateTotal() {
var ship = form.querySelector('input[name="ship"]:checked').value;
totalEl.textContent = '$' + (48 + prices[ship]).toFixed(2);
}
function show(n, moveFocus) {
i = n;
panes.forEach(function (p, k) { p.hidden = k !== i; });
steps.forEach(function (s, k) {
s.classList.toggle('is-done', k < i);
s.classList.toggle('is-current', k === i);
});
label.textContent = 'Step ' + (i + 1) + ' of ' + panes.length;
pct.textContent = ((i + 1) / panes.length * 100) + '%';
back.classList.toggle('invisible', i === 0 || finished);
back.disabled = i === 0 || finished;
next.firstChild.textContent = i === panes.length - 1 ? 'Place order ' : 'Next ';
if (i === panes.length - 1) summary();
if (moveFocus) panes[i].querySelector('legend').focus();
}
next.addEventListener('click', function () {
if (finished) return;
if (!validPane()) return;
if (i < panes.length - 1) show(i + 1, true);
else {
finished = true;
document.getElementById('wDone').classList.remove('d-none');
next.disabled = true; back.disabled = true; back.classList.add('invisible');
label.textContent = 'Order confirmed';
}
});
back.addEventListener('click', function () { if (i > 0) show(i - 1, true); });
form.addEventListener('input', function (e) {
e.target.classList.remove('is-invalid');
e.target.removeAttribute('aria-invalid');
if (e.target.name === 'ship') updateTotal();
});
form.addEventListener('change', function (e) { if (e.target.name === 'ship') updateTotal(); });
form.addEventListener('submit', function (e) { e.preventDefault(); });
show(0, false);
}
initWizard();
})();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.