Bootstrap 5 Multi-Step Form Wizard with Validation
A three-step form wizard with a progress stepper that fills as you go, website-type option cards, per-step validation and a recap on the confirmation screen.
<section class="wdw-stage">
<div class="container" style="max-width: 860px">
<ol class="fw-steps list-unstyled d-flex mb-4" aria-label="Progress">
<li class="fw-step is-current" data-step="1"><span class="fw-dot">1</span><span class="fw-label">Build</span></li>
<li class="fw-step" data-step="2"><span class="fw-dot">2</span><span class="fw-label">Design</span></li>
<li class="fw-step" data-step="3"><span class="fw-dot">3</span><span class="fw-label">Confirm</span></li>
</ol>
<p class="visually-hidden" role="status" id="fw-status">Step 1 of 3</p>
<form class="wdw-card p-4 p-md-5 py-md-5 fw-form" novalidate>
<div class="fw-pane" data-pane="1">
<span class="wdw-eyebrow">Step 1 of 3</span>
<h2 class="wdw-heading display-6 fs-1 mb-2" tabindex="-1">Who are you building for?</h2>
<p class="wdw-muted fs-5 mb-4">Tell us your name and where to send the estimate.</p>
<div class="row g-3">
<div class="col-md-6">
<div class="form-floating">
<input type="text" class="form-control" id="fw-name" placeholder="Name" autocomplete="name" required>
<label for="fw-name">Name</label>
<div class="invalid-feedback">Please enter a name.</div>
</div>
</div>
<div class="col-md-6">
<div class="form-floating">
<input type="email" class="form-control" id="fw-email" placeholder="Email" autocomplete="email" required>
<label for="fw-email">Email</label>
<div class="invalid-feedback">Please enter a valid email.</div>
</div>
</div>
</div>
</div>
<div class="fw-pane" data-pane="2" hidden>
<span class="wdw-eyebrow">Step 2 of 3</span>
<h2 class="wdw-heading display-6 fs-1 mb-2" tabindex="-1">Describe the website</h2>
<p class="wdw-muted mb-4">Pick a type, then give it a title and a short brief.</p>
<fieldset class="mb-3">
<legend class="visually-hidden">Website type</legend>
<div class="row g-3">
<div class="col-4">
<input type="radio" class="btn-check" name="fw-type" id="fw-t1" value="Portfolio" checked>
<label class="btn fw-type w-100" for="fw-t1">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="3"/><path d="M3 15l5-5 5 5 3-3 5 5"/></svg>Portfolio</label>
</div>
<div class="col-4">
<input type="radio" class="btn-check" name="fw-type" id="fw-t2" value="Online shop">
<label class="btn fw-type w-100" for="fw-t2">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 8h14l-1 12H6zM9 8a3 3 0 0 1 6 0"/></svg>Online shop</label>
</div>
<div class="col-4">
<input type="radio" class="btn-check" name="fw-type" id="fw-t3" value="Blog">
<label class="btn fw-type w-100" for="fw-t3">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 4h14v16H5zM8 9h8M8 13h8M8 17h5"/></svg>Blog</label>
</div>
</div>
</fieldset>
<div class="form-floating mb-3">
<input type="text" class="form-control" id="fw-title" placeholder="Website title" required>
<label for="fw-title">Website title</label>
<div class="invalid-feedback">Please enter a title.</div>
</div>
<div class="form-floating">
<textarea class="form-control" id="fw-desc" placeholder="Description" style="height: 8rem" required></textarea>
<label for="fw-desc">Short description</label>
<div class="invalid-feedback">Please add a short description.</div>
</div>
</div>
<div class="fw-pane" data-pane="3" hidden>
<div class="d-flex align-items-center gap-3 mb-4">
<span class="wdw-icon rounded-circle text-success" style="width:3.5rem;height:3.5rem;background:var(--bs-success-bg-subtle)" aria-hidden="true">
<svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>
</span>
<div>
<h2 class="wdw-heading display-6 fs-2 mb-0" tabindex="-1">Thank you!</h2>
<p class="wdw-muted mb-0">An estimate will be sent to <strong class="text-body-emphasis" id="fw-sent">your inbox</strong>.</p>
</div>
</div>
<dl class="row g-0 mb-0 rounded-3 bg-body-tertiary p-3">
<dt class="col-sm-4 wdw-muted fw-semibold">Name</dt><dd class="col-sm-8 mb-2" id="fw-r-name"></dd>
<dt class="col-sm-4 wdw-muted fw-semibold">Email</dt><dd class="col-sm-8 mb-2" id="fw-r-email"></dd>
<dt class="col-sm-4 wdw-muted fw-semibold">Type</dt><dd class="col-sm-8 mb-2" id="fw-r-type"></dd>
<dt class="col-sm-4 wdw-muted fw-semibold">Title</dt><dd class="col-sm-8 mb-0" id="fw-r-title"></dd>
</dl>
</div>
<div class="d-flex justify-content-between align-items-center mt-4 fw-actions">
<button type="button" class="btn btn-outline-secondary rounded-pill px-4 fw-back">Back</button>
<button type="submit" class="btn btn-primary rounded-pill px-4 fw-next">Next
<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 12h14M13 6l6 6-6 6"/></svg></button>
</div>
</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 */
.fw-steps { position: relative; justify-content: space-between; padding-inline: 1rem; --fw-progress: 0%; }
.fw-steps::before, .fw-steps::after { content: ""; position: absolute; top: 1.125rem; left: 3rem; height: 3px; border-radius: 2px; }
.fw-steps::before { right: 3rem; background: var(--bs-border-color); }
.fw-steps::after { width: calc((100% - 6rem) * var(--fw-progress) / 100); background: var(--bs-primary); transition: width .4s ease; }
.fw-step { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: .5rem; min-width: 4rem; }
.fw-dot { width: 2.5rem; height: 2.5rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .95rem; background: var(--bs-body-bg); border: 2px solid var(--bs-border-color); color: var(--bs-secondary-color); transition: background-color .25s, border-color .25s, color .25s; }
.fw-label { font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--bs-secondary-color); }
.fw-step.is-current .fw-dot { border-color: var(--bs-primary); color: var(--bs-primary); box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.fw-step.is-current .fw-label { color: var(--bs-emphasis-color); }
.fw-step.is-done .fw-dot { background: var(--bs-primary); border-color: var(--bs-primary); color: #fff; font-size: 0; }
.fw-step.is-done .fw-dot::before { content: ""; width: .5rem; height: .9rem; border: solid currentColor; border-width: 0 3px 3px 0; transform: rotate(45deg) translate(-1px, -1px); }
[data-bs-theme="dark"] .fw-step.is-done .fw-dot { color: #0f1117; }
.fw-pane:not([hidden]) { animation: fw-in .3s ease; }
.fw-pane h2:focus { outline: none; }
@keyframes fw-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .fw-pane:not([hidden]) { animation: none; } .fw-dot, .fw-steps::after { transition: none; } }
.fw-form textarea.form-control { height: 8rem; min-height: 8rem; }
.fw-type { display: flex; flex-direction: column; align-items: center; gap: .5rem; padding: 1rem .5rem; min-height: 5.5rem; border: 1px solid var(--bs-border-color); border-radius: 1rem; background: var(--bs-body-bg); color: var(--bs-body-color); font-weight: 600; font-size: .9rem; }
.fw-type:hover { border-color: var(--bs-primary); color: var(--bs-body-color); }
.btn-check:checked + .fw-type { border-color: var(--bs-primary); background: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis); box-shadow: 0 0 0 1px var(--bs-primary); }
.btn-check:focus-visible + .fw-type { box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.fw-back.is-hidden { visibility: hidden; }
.fw-form .form-floating > .form-control { min-height: 3.75rem; }
function initFormWizard() {
var form = document.querySelector('.fw-form');
if (!form) return;
var panes = form.querySelectorAll('.fw-pane');
var steps = document.querySelectorAll('.fw-step');
var track = document.querySelector('.fw-steps');
var status = document.getElementById('fw-status');
var back = form.querySelector('.fw-back');
var next = form.querySelector('.fw-next');
var current = 0;
function val(id) { return document.getElementById(id).value.trim(); }
function show(n, moveFocus) {
current = n;
panes.forEach(function (p, i) { p.hidden = i !== n; });
steps.forEach(function (s, i) {
s.classList.toggle('is-current', i === n);
s.classList.toggle('is-done', i < n);
if (i === n) s.setAttribute('aria-current', 'step'); else s.removeAttribute('aria-current');
});
track.style.setProperty('--fw-progress', (n / (panes.length - 1) * 100) + '%');
back.classList.toggle('is-hidden', n === 0);
back.tabIndex = n === 0 ? -1 : 0;
status.textContent = 'Step ' + (n + 1) + ' of ' + panes.length;
if (n === panes.length - 1) {
form.querySelector('.fw-actions').classList.add('d-none');
var email = val('fw-email');
if (email) document.getElementById('fw-sent').textContent = email;
document.getElementById('fw-r-name').textContent = val('fw-name');
document.getElementById('fw-r-email').textContent = email;
document.getElementById('fw-r-title').textContent = val('fw-title');
var type = form.querySelector('input[name="fw-type"]:checked');
document.getElementById('fw-r-type').textContent = type ? type.value : '';
} else {
next.firstChild.textContent = n === panes.length - 2 ? 'Submit ' : 'Next ';
}
if (moveFocus) {
var h = panes[n].querySelector('h2');
if (h) h.focus();
}
}
function validPane(n) {
var ok = true;
panes[n].querySelectorAll('input[type="text"], input[type="email"], textarea').forEach(function (f) {
var v = f.checkValidity() && f.value.trim() !== '';
f.classList.toggle('is-invalid', !v);
if (!v) ok = false;
});
var first = panes[n].querySelector('.is-invalid');
if (first) first.focus();
return ok;
}
form.addEventListener('submit', function (e) {
e.preventDefault();
if (validPane(current)) show(current + 1, true);
});
form.addEventListener('input', function (e) { e.target.classList.remove('is-invalid'); });
back.addEventListener('click', function () { if (current > 0) show(current - 1, true); });
show(0, false);
}
initFormWizard();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.