Wizard tabs in HTML, CSS and vanilla JS
A copy-paste Wizard tabs in plain HTML and CSS, with vanilla JavaScript: no framework, no build step, MIT-licensed.
Live preview
Source (copy-ready)
<section class="dcl-wizard-tabs" data-dcl-scheme="light" aria-labelledby="dcl-wizard-tabs-title"><header class="dcl-wizard-tabs__header"><h2 id="dcl-wizard-tabs-title">Wizard tabs</h2><p class="dcl-wizard-tabs__muted">Tabs act as inspectable milestones in a short guided flow.</p></header><p class="dcl-wizard-tabs__muted" role="status" aria-live="polite" data-step-note>Step 1 of 3</p><div class="dcl-wizard-tabs__tabs" role="tablist" aria-label="Example topics"><button type="button" role="tab" id="dcl-wizard-tabs-tab-0" aria-controls="dcl-wizard-tabs-panel-0" aria-selected="true" tabindex="0">Scope</button><button type="button" role="tab" id="dcl-wizard-tabs-tab-1" aria-controls="dcl-wizard-tabs-panel-1" aria-selected="false" tabindex="-1">Validate</button><button type="button" role="tab" id="dcl-wizard-tabs-tab-2" aria-controls="dcl-wizard-tabs-panel-2" aria-selected="false" tabindex="-1">Approve</button></div><div class="dcl-wizard-tabs__panels"><section role="tabpanel" id="dcl-wizard-tabs-panel-0" aria-labelledby="dcl-wizard-tabs-tab-0"><p>Choose the records in scope.</p><button type="button" class="dcl-wizard-tabs__primary" data-next>Continue</button></section><section role="tabpanel" id="dcl-wizard-tabs-panel-1" aria-labelledby="dcl-wizard-tabs-tab-1" hidden><p>Check counts and ownership.</p><button type="button" data-back>Back</button><button type="button" class="dcl-wizard-tabs__primary" data-next>Continue</button></section><section role="tabpanel" id="dcl-wizard-tabs-panel-2" aria-labelledby="dcl-wizard-tabs-tab-2" hidden><p>Approve the migration window.</p><button type="button" data-back>Back</button><button type="button" class="dcl-wizard-tabs__primary" data-done>Finish</button></section></div><script>(()=>{const root=document.currentScript.closest(".dcl-wizard-tabs");if(!root||root.dataset.dclBound)return;root.dataset.dclBound="1";const instance=Array.from(document.getElementsByClassName("dcl-wizard-tabs")).indexOf(root);if(instance>0){for(const el of [root,...root.querySelectorAll("*")]){for(const attr of ["id","aria-labelledby","aria-controls","aria-describedby","for","name"]){if(el.hasAttribute(attr))el.setAttribute(attr,el.getAttribute(attr)+"--"+instance)}const href=el.getAttribute("href");if(href&&href.startsWith("#"))el.setAttribute("href",href+"--"+instance)}}const preference=matchMedia("(prefers-color-scheme: dark)"),apply=()=>{root.dataset.dclScheme=preference.matches?"dark":"light"};preference.addEventListener("change",apply);apply();const q=(s)=>root.querySelector(s),qa=(s)=>Array.from(root.querySelectorAll(s));const tabs=qa('[role="tab"]'),panels=qa('[role="tabpanel"]');panels.forEach(p=>p.tabIndex=0);function activate(tab,focus=true){tabs.forEach(t=>{const on=t===tab;t.setAttribute("aria-selected",on);t.tabIndex=on?0:-1;document.getElementById(t.getAttribute("aria-controls")).hidden=!on});if(focus)tab.focus()}tabs.forEach((t,i)=>{t.addEventListener("click",()=>activate(t,false));t.addEventListener("keydown",e=>{let n;if(e.key==="ArrowRight")n=(i+1)%tabs.length;else if(e.key==="ArrowLeft")n=(i+tabs.length-1)%tabs.length;else if(e.key==="Home")n=0;else if(e.key==="End")n=tabs.length-1;else return;e.preventDefault();activate(tabs[n])})});const note=q("[data-step-note]");function update(){const i=tabs.findIndex(t=>t.getAttribute("aria-selected")==="true");if(note)note.textContent="Step "+(i+1)+" of "+tabs.length}qa("[data-next]").forEach(b=>b.addEventListener("click",()=>{const i=tabs.findIndex(t=>t.getAttribute("aria-selected")==="true");activate(tabs[Math.min(i+1,tabs.length-1)]);update()}));qa("[data-back]").forEach(b=>b.addEventListener("click",()=>{const i=tabs.findIndex(t=>t.getAttribute("aria-selected")==="true");activate(tabs[Math.max(i-1,0)]);update()}));tabs.forEach(t=>t.addEventListener("click",update));const done=q("[data-done]");if(done)done.addEventListener("click",()=>{if(note)note.textContent="Wizard review complete"});update();})();</script></section>
<style>
.dcl-wizard-tabs{color:#11292f;background-color:#ffffff;color-scheme:light;font:1rem/1.45 system-ui,sans-serif;padding:.8rem;border:1px solid #697f84;border-radius:.6rem;overflow-wrap:anywhere}
.dcl-wizard-tabs *{box-sizing:border-box}.dcl-wizard-tabs h2,.dcl-wizard-tabs h3{line-height:1.15;margin-block:0 .6rem}.dcl-wizard-tabs a{color:#005c62}
.dcl-wizard-tabs button,.dcl-wizard-tabs input,.dcl-wizard-tabs select,.dcl-wizard-tabs textarea,.dcl-wizard-tabs summary{min-block-size:44px;border:1px solid #697f84;border-radius:.3rem;padding:.4rem .65rem;font:inherit;color:#11292f;background-color:#e4edef}
.dcl-wizard-tabs input,.dcl-wizard-tabs select,.dcl-wizard-tabs textarea{background-color:#ffffff}.dcl-wizard-tabs input[type="radio"],.dcl-wizard-tabs input[type="checkbox"]{min-block-size:auto;inline-size:auto}
.dcl-wizard-tabs button,.dcl-wizard-tabs summary{cursor:pointer}.dcl-wizard-tabs button:hover,.dcl-wizard-tabs summary:hover{color:#ffffff;background-color:#00535a}
.dcl-wizard-tabs button:focus-visible,.dcl-wizard-tabs input:focus-visible,.dcl-wizard-tabs select:focus-visible,.dcl-wizard-tabs textarea:focus-visible,.dcl-wizard-tabs summary:focus-visible,.dcl-wizard-tabs a:focus-visible{outline:3px solid #005c62;outline-offset:2px}
.dcl-wizard-tabs details{color:#11292f;background-color:#ffffff;border:1px solid #697f84;border-radius:.4rem;margin-block-start:.6rem}.dcl-wizard-tabs summary{font-weight:650}
.dcl-wizard-tabs dialog{color:#11292f;background-color:#ffffff;border:1px solid #697f84;border-radius:.6rem;max-inline-size:min(34rem,92vw);padding:1rem}
.dcl-wizard-tabs table{border-collapse:collapse;inline-size:100%;color:#11292f;background-color:#ffffff}.dcl-wizard-tabs th,.dcl-wizard-tabs td{padding:.4rem;text-align:start;border-block-end:1px solid #697f84}.dcl-wizard-tabs th{color:#11292f;background-color:#e4edef}
.dcl-wizard-tabs [hidden]{display:none!important}.dcl-wizard-tabs__muted{color:#405a60}.dcl-wizard-tabs__panel{color:#405a60;background-color:#ffffff}.dcl-wizard-tabs__well{color:#11292f;background-color:#e4edef}.dcl-wizard-tabs__primary,.dcl-wizard-tabs__badge{color:#ffffff;background-color:#00535a}.dcl-wizard-tabs__badge{border-radius:999px;padding:.1rem .45rem;font-size:.8rem;font-weight:700}
.dcl-wizard-tabs[data-dcl-scheme="dark"]{color:#eff8f9;background-color:#142f36;color-scheme:dark;border-color:#839fa5}.dcl-wizard-tabs[data-dcl-scheme="dark"] a{color:#8fe1da}
.dcl-wizard-tabs[data-dcl-scheme="dark"] button,.dcl-wizard-tabs[data-dcl-scheme="dark"] input,.dcl-wizard-tabs[data-dcl-scheme="dark"] select,.dcl-wizard-tabs[data-dcl-scheme="dark"] textarea,.dcl-wizard-tabs[data-dcl-scheme="dark"] summary{color:#eff8f9;background-color:#1c3c44;border-color:#839fa5}
.dcl-wizard-tabs[data-dcl-scheme="dark"] input,.dcl-wizard-tabs[data-dcl-scheme="dark"] select,.dcl-wizard-tabs[data-dcl-scheme="dark"] textarea{background-color:#142f36}.dcl-wizard-tabs[data-dcl-scheme="dark"] button:hover,.dcl-wizard-tabs[data-dcl-scheme="dark"] summary:hover{color:#11292f;background-color:#8fe1da}
.dcl-wizard-tabs[data-dcl-scheme="dark"] button:focus-visible,.dcl-wizard-tabs[data-dcl-scheme="dark"] input:focus-visible,.dcl-wizard-tabs[data-dcl-scheme="dark"] select:focus-visible,.dcl-wizard-tabs[data-dcl-scheme="dark"] textarea:focus-visible,.dcl-wizard-tabs[data-dcl-scheme="dark"] summary:focus-visible,.dcl-wizard-tabs[data-dcl-scheme="dark"] a:focus-visible{outline-color:#8fe1da}
.dcl-wizard-tabs[data-dcl-scheme="dark"] details,.dcl-wizard-tabs[data-dcl-scheme="dark"] dialog,.dcl-wizard-tabs[data-dcl-scheme="dark"] table{color:#eff8f9;background-color:#142f36;border-color:#839fa5}.dcl-wizard-tabs[data-dcl-scheme="dark"] th{color:#eff8f9;background-color:#1c3c44}.dcl-wizard-tabs[data-dcl-scheme="dark"] th,.dcl-wizard-tabs[data-dcl-scheme="dark"] td{border-color:#839fa5}
.dcl-wizard-tabs[data-dcl-scheme="dark"] .dcl-wizard-tabs__muted{color:#b0c9ce}.dcl-wizard-tabs[data-dcl-scheme="dark"] .dcl-wizard-tabs__panel{color:#b0c9ce;background-color:#142f36}.dcl-wizard-tabs[data-dcl-scheme="dark"] .dcl-wizard-tabs__well{color:#eff8f9;background-color:#1c3c44}.dcl-wizard-tabs[data-dcl-scheme="dark"] .dcl-wizard-tabs__primary,.dcl-wizard-tabs[data-dcl-scheme="dark"] .dcl-wizard-tabs__badge{color:#11292f;background-color:#8fe1da}
@media (prefers-reduced-motion:reduce){.dcl-wizard-tabs *{transition:none!important;animation:none!important}}
.dcl-wizard-tabs__tabs{display:grid;grid-template-columns:repeat(3,1fr);gap:.4rem}.dcl-wizard-tabs [role="tab"][aria-selected="true"]{color:#ffffff;background-color:#00535a}.dcl-wizard-tabs[data-dcl-scheme="dark"] [role="tab"][aria-selected="true"]{color:#11292f;background-color:#8fe1da}@media(max-width:34rem){.dcl-wizard-tabs__tabs{grid-template-columns:1fr}}</style>
When to use
Use for a short linear review where users may inspect steps out of order but usually proceed in sequence. Keep validation outside the tab control itself.
Avoid
Do not use tabs as the only progress indicator for a long form; use a dedicated multi-page form with validation and recovery.
Accessibility
Wizard steps remain real tabs with arrows, Home and End, while Back and Continue buttons move focus to the appropriate tab. Progress is exposed as text in a live region. Light body text is #405a60 on #ffffff (7.37:1) or #11292f on #e4edef (12.78:1); dark body text is #b0c9ce on #142f36 (8.12:1) or #eff8f9 on #1c3c44 (10.94:1). Focus is shown with a 3px outline.
Was this useful? Send feedback.