SaaS — Onboarding Wizard
A welcoming, momentum-building onboarding wizard for a fictional SaaS product. A four-step flow guides new users from creating a workspace, to inviting teammates, connecting a data source, and customizing their accent and theme. A live progress ring tracks overall completion, every step validates and persists to localStorage, skip-for-now keeps things moving, and a celebratory confetti finish wraps it up. Built with semantic HTML, CSS, and vanilla JavaScript, with light and dark parity.
MCP
Code
:root {
--bg: #f7f8fb;
--surface: #ffffff;
--surface-2: #f1f3f9;
--ink: #0f1222;
--muted: #646b85;
--brand: #6366f1;
--brand-d: #4f46e5;
--ok: #16a34a;
--warn: #d97706;
--danger: #dc2626;
--line: rgba(15, 18, 34, .1);
--line-2: rgba(15, 18, 34, .06);
--ring-track: rgba(15, 18, 34, .08);
--shadow: 0 1px 2px rgba(15, 18, 34, .06), 0 8px 24px rgba(15, 18, 34, .06);
--radius: 14px;
}
[data-theme="dark"] {
--bg: #0b0d17;
--surface: #14172a;
--surface-2: #1b1f38;
--ink: #eef0f8;
--muted: #9aa2c0;
--line: rgba(255, 255, 255, .12);
--line-2: rgba(255, 255, 255, .07);
--ring-track: rgba(255, 255, 255, .12);
--shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 14px 38px rgba(0, 0, 0, .45);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
margin: 0;
font-family: "Inter", system-ui, -apple-system, sans-serif;
background: var(--bg);
color: var(--ink);
line-height: 1.5;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
min-height: 100vh;
display: grid;
place-items: center;
padding: 24px;
transition: background .25s ease, color .25s ease;
}
.skip-link {
position: absolute;
left: 12px;
top: -48px;
background: var(--brand);
color: #fff;
padding: 8px 14px;
border-radius: 8px;
z-index: 50;
transition: top .2s;
}
.skip-link:focus { top: 12px; }
:focus-visible {
outline: 2px solid var(--brand);
outline-offset: 2px;
border-radius: 6px;
}
/* ---- Shell ---- */
.shell {
width: min(960px, 100%);
background: var(--surface);
border: 1px solid var(--line);
border-radius: 22px;
box-shadow: var(--shadow);
display: grid;
grid-template-columns: 300px 1fr;
overflow: hidden;
min-height: 580px;
}
/* ---- Rail ---- */
.rail {
background: var(--surface-2);
border-right: 1px solid var(--line);
padding: 26px 22px;
display: flex;
flex-direction: column;
gap: 22px;
}
.brand {
display: flex;
align-items: center;
gap: 10px;
font-weight: 800;
font-size: 1.05rem;
letter-spacing: -.01em;
}
.logo {
width: 34px;
height: 34px;
border-radius: 9px;
display: grid;
place-items: center;
color: #fff;
background: linear-gradient(135deg, var(--brand), var(--brand-d));
box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 40%, transparent);
}
.ring-wrap {
position: relative;
width: 132px;
height: 132px;
margin: 2px auto 4px;
}
.ring { width: 132px; height: 132px; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--ring-track); stroke-width: 9; }
.ring-fill {
fill: none;
stroke: var(--brand);
stroke-width: 9;
stroke-linecap: round;
stroke-dasharray: 326.7;
stroke-dashoffset: 326.7;
transition: stroke-dashoffset .6s cubic-bezier(.22, 1, .36, 1);
}
.ring-center {
position: absolute;
inset: 0;
display: grid;
place-content: center;
text-align: center;
line-height: 1.1;
}
.ring-center strong { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; }
.ring-center span { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
/* ---- Steps ---- */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.step-btn {
width: 100%;
display: flex;
align-items: center;
gap: 12px;
padding: 10px 10px;
background: transparent;
border: 0;
border-radius: 11px;
cursor: pointer;
text-align: left;
color: var(--ink);
font: inherit;
transition: background .15s;
}
.step-btn:hover { background: var(--surface); }
.step.active .step-btn { background: var(--surface); box-shadow: var(--shadow); }
.step-mark {
flex: none;
width: 28px;
height: 28px;
border-radius: 50%;
display: grid;
place-items: center;
font-size: .82rem;
font-weight: 700;
background: var(--surface);
border: 1.5px solid var(--line);
color: var(--muted);
transition: all .2s;
}
.step.active .step-mark { border-color: var(--brand); color: var(--brand); }
.step.complete .step-mark {
background: var(--ok);
border-color: var(--ok);
color: #fff;
font-size: 0;
}
.step.complete .step-mark::after {
content: "✓";
font-size: .9rem;
}
.step-text { display: flex; flex-direction: column; min-width: 0; }
.step-title { font-weight: 600; font-size: .92rem; letter-spacing: -.01em; }
.step-sub { font-size: .76rem; color: var(--muted); }
.reset-btn {
margin-top: auto;
align-self: flex-start;
background: none;
border: 0;
color: var(--muted);
font: inherit;
font-size: .82rem;
cursor: pointer;
padding: 4px 2px;
text-decoration: underline;
text-underline-offset: 3px;
}
.reset-btn:hover { color: var(--danger); }
/* ---- Panel ---- */
.panel {
padding: 26px 32px 22px;
display: flex;
flex-direction: column;
position: relative;
}
.panel-head {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 14px;
}
.eyebrow {
margin: 0;
font-size: .78rem;
font-weight: 700;
letter-spacing: .07em;
text-transform: uppercase;
color: var(--brand);
}
.stage { flex: 1; animation: rise .35s ease both; }
@keyframes rise {
from { opacity: 0; transform: translateY(8px); }
to { opacity: 1; transform: translateY(0); }
}
.stage-title { margin: 0 0 6px; font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; }
.stage-lead { margin: 0 0 22px; color: var(--muted); max-width: 46ch; }
/* ---- Forms ---- */
.form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field-label { font-size: .86rem; font-weight: 600; }
.choice-set legend { padding: 0; }
input[type="text"], input[type="email"] {
width: 100%;
padding: 11px 13px;
font: inherit;
color: var(--ink);
background: var(--surface);
border: 1.5px solid var(--line);
border-radius: 10px;
transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--muted); opacity: .8; }
input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); outline: none; }
input[aria-invalid="true"] { border-color: var(--danger); }
.url-input {
display: flex;
align-items: stretch;
border: 1.5px solid var(--line);
border-radius: 10px;
overflow: hidden;
transition: border-color .15s, box-shadow .15s;
}
.url-input:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.url-prefix {
display: grid;
place-items: center;
padding: 0 12px;
background: var(--surface-2);
color: var(--muted);
font-size: .88rem;
border-right: 1px solid var(--line);
white-space: nowrap;
}
.url-input input { border: 0; border-radius: 0; }
.url-input input:focus { box-shadow: none; }
.error { color: var(--danger); font-size: .8rem; min-height: 1em; }
/* chips / radios */
.chips, .swatches { display: flex; flex-wrap: wrap; gap: 9px; }
.chip {
padding: 9px 16px;
border: 1.5px solid var(--line);
background: var(--surface);
border-radius: 999px;
font: inherit;
font-size: .88rem;
font-weight: 500;
color: var(--ink);
cursor: pointer;
transition: all .15s;
}
.chip:hover { border-color: color-mix(in srgb, var(--brand) 50%, var(--line)); }
.chip[aria-checked="true"] {
background: color-mix(in srgb, var(--brand) 14%, transparent);
border-color: var(--brand);
color: var(--brand-d);
}
[data-theme="dark"] .chip[aria-checked="true"] { color: #fff; }
.swatch {
width: 38px;
height: 38px;
border-radius: 50%;
border: 2px solid var(--line);
background: var(--sw);
cursor: pointer;
position: relative;
transition: transform .12s, box-shadow .15s;
}
.swatch:hover { transform: scale(1.08); }
.swatch[aria-checked="true"] {
box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--sw);
border-color: var(--surface);
}
.swatch[aria-checked="true"]::after {
content: "✓";
position: absolute;
inset: 0;
display: grid;
place-items: center;
color: #fff;
font-weight: 800;
font-size: 1rem;
}
/* ---- Invites ---- */
.invite-row { display: flex; gap: 10px; align-items: flex-end; }
.field.grow { flex: 1; }
.add-invite { flex: none; height: 45px; }
.invite-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.invite-item {
display: flex;
align-items: center;
gap: 12px;
padding: 10px 12px;
background: var(--surface-2);
border: 1px solid var(--line-2);
border-radius: 11px;
animation: rise .25s ease both;
}
.av {
width: 34px;
height: 34px;
border-radius: 50%;
display: grid;
place-items: center;
font-weight: 700;
font-size: .82rem;
color: #fff;
flex: none;
}
.invite-item .em { flex: 1; font-size: .9rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invite-item .role { font-size: .76rem; color: var(--muted); }
.invite-item .rm {
border: 0;
background: none;
color: var(--muted);
cursor: pointer;
font-size: 1.1rem;
line-height: 1;
padding: 4px 6px;
border-radius: 7px;
}
.invite-item .rm:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.empty { color: var(--muted); font-size: .9rem; padding: 8px 2px; }
.empty[hidden] { display: none; }
/* ---- Sources ---- */
.sources { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.source {
display: flex;
align-items: center;
gap: 12px;
padding: 14px;
background: var(--surface);
border: 1.5px solid var(--line);
border-radius: 13px;
cursor: pointer;
text-align: left;
font: inherit;
color: var(--ink);
transition: all .15s;
}
.source:hover { border-color: color-mix(in srgb, var(--brand) 50%, var(--line)); transform: translateY(-1px); box-shadow: var(--shadow); }
.src-ic {
width: 40px;
height: 40px;
border-radius: 10px;
display: grid;
place-items: center;
font-size: 1.2rem;
font-weight: 800;
flex: none;
color: #fff;
}
.src-ic.gh { background: #24292f; }
.src-ic.sl { background: #4a154b; }
.src-ic.st { background: #635bff; }
.src-ic.pg { background: #336791; }
.src-meta { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.src-meta strong { font-size: .94rem; }
.src-meta small { color: var(--muted); font-size: .8rem; }
.src-state {
flex: none;
font-size: .8rem;
font-weight: 600;
color: var(--brand-d);
padding: 5px 11px;
border-radius: 999px;
background: color-mix(in srgb, var(--brand) 12%, transparent);
}
.source.connected { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 7%, var(--surface)); }
.source.connected .src-state { background: var(--ok); color: #fff; }
/* ---- Switch ---- */
.switch-row {
display: flex;
align-items: center;
gap: 12px;
padding: 14px;
border: 1px solid var(--line);
border-radius: 12px;
cursor: pointer;
background: var(--surface);
}
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
flex: none;
width: 42px;
height: 24px;
border-radius: 999px;
background: var(--line);
position: relative;
transition: background .2s;
}
.switch::after {
content: "";
position: absolute;
top: 3px;
left: 3px;
width: 18px;
height: 18px;
border-radius: 50%;
background: #fff;
box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
transition: transform .2s;
}
.switch-row input:checked + .switch { background: var(--brand); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch-text { display: flex; flex-direction: column; }
.switch-text strong { font-size: .92rem; }
.switch-text small { color: var(--muted); font-size: .82rem; }
/* ---- Buttons ---- */
.primary {
background: linear-gradient(180deg, var(--brand), var(--brand-d));
color: #fff;
border: 0;
padding: 11px 20px;
border-radius: 10px;
font: inherit;
font-weight: 600;
cursor: pointer;
box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 35%, transparent);
transition: transform .1s, box-shadow .15s, opacity .15s;
}
.primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 45%, transparent); }
.primary:active { transform: translateY(0); }
.primary.big { padding: 14px 28px; font-size: 1rem; }
.ghost {
background: var(--surface);
color: var(--ink);
border: 1.5px solid var(--line);
padding: 10px 16px;
border-radius: 10px;
font: inherit;
font-weight: 500;
cursor: pointer;
transition: background .15s, border-color .15s;
}
.ghost:hover { background: var(--surface-2); }
.theme-toggle { font-size: .85rem; padding: 7px 13px; }
.t-icon { margin-right: 4px; }
.link {
background: none;
border: 0;
color: var(--muted);
font: inherit;
font-weight: 500;
cursor: pointer;
padding: 10px 8px;
border-radius: 8px;
}
.link:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
/* ---- Footer ---- */
.panel-foot {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-top: 20px;
padding-top: 18px;
border-top: 1px solid var(--line);
}
.foot-right { display: flex; align-items: center; gap: 6px; }
.panel-foot[hidden] { display: none; }
.backBtn[disabled], .ghost[disabled] { opacity: .4; cursor: not-allowed; }
/* ---- Done ---- */
.done-stage {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
gap: 4px;
position: relative;
overflow: hidden;
}
.done-badge {
width: 72px;
height: 72px;
border-radius: 50%;
display: grid;
place-items: center;
color: #fff;
background: linear-gradient(135deg, var(--ok), #15803d);
box-shadow: 0 8px 24px color-mix(in srgb, var(--ok) 40%, transparent);
margin-bottom: 14px;
animation: pop .5s cubic-bezier(.34, 1.56, .64, 1) both;
}
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
.done-stage .stage-lead { margin-bottom: 18px; }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i {
position: absolute;
top: -12px;
width: 9px;
height: 14px;
border-radius: 2px;
animation: fall linear forwards;
}
@keyframes fall {
to { transform: translateY(620px) rotate(640deg); opacity: 0; }
}
/* ---- Toast ---- */
.toast-host {
position: fixed;
bottom: 22px;
left: 50%;
transform: translateX(-50%);
display: flex;
flex-direction: column;
gap: 8px;
z-index: 100;
width: max-content;
max-width: 90vw;
}
.toast {
background: var(--ink);
color: var(--bg);
padding: 11px 16px;
border-radius: 11px;
font-size: .88rem;
font-weight: 500;
box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
animation: toastIn .25s ease both;
display: flex;
align-items: center;
gap: 8px;
}
.toast.out { animation: toastOut .25s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(12px); } }
/* ---- Responsive ---- */
@media (max-width: 760px) {
body { padding: 0; }
.shell {
grid-template-columns: 1fr;
border-radius: 0;
min-height: 100vh;
border: 0;
}
.rail {
flex-direction: row;
flex-wrap: wrap;
align-items: center;
gap: 16px;
border-right: 0;
border-bottom: 1px solid var(--line);
padding: 18px;
}
.brand { width: 100%; }
.ring-wrap { width: 84px; height: 84px; margin: 0; }
.ring, .ring-center strong { }
.ring { width: 84px; height: 84px; }
.ring-center strong { font-size: 1.1rem; }
.ring-center span { font-size: .6rem; }
.steps { flex: 1; min-width: 200px; }
.step-sub { display: none; }
.reset-btn { width: 100%; margin-top: 4px; }
}
@media (max-width: 480px) {
.panel { padding: 20px; }
.stage-title { font-size: 1.3rem; }
.sources { grid-template-columns: 1fr; }
.steps { display: none; }
.invite-row { flex-direction: column; align-items: stretch; }
.add-invite { height: auto; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}(function () {
"use strict";
var STORE_KEY = "northwind.onboarding.v1";
var TOTAL = 4; // four real steps
var AVATAR_COLORS = ["#6366f1", "#0ea5e9", "#10b981", "#f59e0b", "#ec4899", "#8b5cf6"];
/* ---------- state ---------- */
var defaults = {
step: 0,
theme: "light",
workspace: { name: "", slug: "", use: "" },
invites: [],
sources: [],
accent: "#6366f1",
density: "Comfortable",
digest: true,
finished: false
};
var state = load();
function load() {
try {
var raw = localStorage.getItem(STORE_KEY);
if (!raw) return clone(defaults);
var parsed = JSON.parse(raw);
return Object.assign(clone(defaults), parsed, {
workspace: Object.assign(clone(defaults.workspace), parsed.workspace || {})
});
} catch (e) {
return clone(defaults);
}
}
function clone(o) { return JSON.parse(JSON.stringify(o)); }
function save() {
try { localStorage.setItem(STORE_KEY, JSON.stringify(state)); } catch (e) {}
}
/* ---------- toast ---------- */
var toastHost = document.getElementById("toastHost");
function toast(msg) {
var el = document.createElement("div");
el.className = "toast";
el.textContent = msg;
toastHost.appendChild(el);
setTimeout(function () {
el.classList.add("out");
setTimeout(function () { el.remove(); }, 250);
}, 2600);
}
/* ---------- element refs ---------- */
var stagesEls = {};
document.querySelectorAll(".stage").forEach(function (s) {
stagesEls[s.getAttribute("data-stage")] = s;
});
var stepEls = Array.prototype.slice.call(document.querySelectorAll(".step"));
var ringFill = document.querySelector(".ring-fill");
var ringPct = document.getElementById("ringPct");
var eyebrow = document.getElementById("eyebrow");
var foot = document.getElementById("panelFoot");
var backBtn = document.getElementById("backBtn");
var nextBtn = document.getElementById("nextBtn");
var skipBtn = document.getElementById("skipBtn");
var RING_CIRC = 2 * Math.PI * 52; // ~326.7
/* ---------- progress ---------- */
function stepDone(i) {
if (i === 0) return !!(state.workspace.name && state.workspace.slug && state.workspace.use);
if (i === 1) return state.invites.length > 0;
if (i === 2) return state.sources.length > 0;
if (i === 3) return !!(state.accent && state.density);
return false;
}
function completedCount() {
var n = 0;
for (var i = 0; i < TOTAL; i++) if (stepDone(i)) n++;
return n;
}
function renderProgress() {
var pct = Math.round((completedCount() / TOTAL) * 100);
ringPct.textContent = pct + "%";
ringFill.style.strokeDashoffset = RING_CIRC * (1 - pct / 100);
stepEls.forEach(function (el, i) {
el.classList.toggle("complete", stepDone(i));
el.classList.toggle("active", state.step === i && !state.finished);
if (state.step === i && !state.finished) el.setAttribute("aria-current", "step");
else el.removeAttribute("aria-current");
});
}
/* ---------- navigation ---------- */
function showStage(key) {
Object.keys(stagesEls).forEach(function (k) {
stagesEls[k].hidden = k !== String(key);
});
// re-trigger entry animation
var active = stagesEls[String(key)];
if (active) { active.style.animation = "none"; void active.offsetWidth; active.style.animation = ""; }
}
function goTo(i) {
state.step = i;
state.finished = false;
showStage(i);
eyebrow.textContent = "Step " + (i + 1) + " of " + TOTAL;
foot.hidden = false;
backBtn.disabled = i === 0;
nextBtn.textContent = i === TOTAL - 1 ? "Finish setup" : "Continue";
skipBtn.hidden = false;
save();
renderProgress();
var input = stagesEls[i].querySelector("input");
if (input) try { input.focus({ preventScroll: true }); } catch (e) {}
}
function finish() {
state.finished = true;
state.step = TOTAL;
showStage("done");
eyebrow.textContent = "All done";
foot.hidden = true;
save();
renderProgress();
buildSummary();
launchConfetti();
toast("Setup complete — welcome aboard! 🎉");
}
/* ---------- validation ---------- */
function setError(stageEl, name, msg) {
var slot = stageEl.querySelector('[data-err="' + name + '"]');
var input = stageEl.querySelector("#" + name) || stageEl.querySelector('[name="' + name + '"]');
if (slot) slot.textContent = msg || "";
if (input) {
if (msg) input.setAttribute("aria-invalid", "true");
else input.removeAttribute("aria-invalid");
}
}
function validateStep(i) {
if (i === 0) {
var ok = true;
var s0 = stagesEls[0];
if (!state.workspace.name.trim()) { setError(s0, "wsName", "Give your workspace a name."); ok = false; }
else setError(s0, "wsName", "");
if (!state.workspace.slug.trim()) { setError(s0, "wsSlug", "Pick a URL for your workspace."); ok = false; }
else setError(s0, "wsSlug", "");
if (!state.workspace.use) { ok = false; toast("Tell us what you'll use Northwind for."); }
return ok;
}
if (i === 1) return state.invites.length > 0;
if (i === 2) return state.sources.length > 0;
if (i === 3) return true;
return true;
}
/* ---------- STEP 0: workspace ---------- */
var wsName = document.getElementById("wsName");
var wsSlug = document.getElementById("wsSlug");
var slugEdited = !!state.workspace.slug;
function slugify(v) {
return v.toLowerCase().trim().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 32);
}
wsName.value = state.workspace.name;
wsSlug.value = state.workspace.slug;
wsName.addEventListener("input", function () {
state.workspace.name = wsName.value;
if (!slugEdited) { wsSlug.value = slugify(wsName.value); state.workspace.slug = wsSlug.value; }
if (wsName.value.trim()) setError(stagesEls[0], "wsName", "");
save(); renderProgress();
});
wsSlug.addEventListener("input", function () {
slugEdited = true;
wsSlug.value = slugify(wsSlug.value);
state.workspace.slug = wsSlug.value;
if (wsSlug.value.trim()) setError(stagesEls[0], "wsSlug", "");
save(); renderProgress();
});
document.querySelectorAll("[data-use]").forEach(function (btn) {
if (btn.getAttribute("data-use") === state.workspace.use) {
btn.setAttribute("aria-checked", "true");
}
btn.addEventListener("click", function () {
document.querySelectorAll("[data-use]").forEach(function (b) { b.setAttribute("aria-checked", "false"); });
btn.setAttribute("aria-checked", "true");
state.workspace.use = btn.getAttribute("data-use");
save(); renderProgress();
});
});
/* ---------- STEP 1: invites ---------- */
var inviteForm = document.getElementById("form1");
var inviteEmail = document.getElementById("inviteEmail");
var inviteList = document.getElementById("inviteList");
var inviteEmpty = document.getElementById("inviteEmpty");
function emailValid(v) { return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v); }
function initials(email) {
var name = email.split("@")[0].replace(/[._-]+/g, " ").trim();
var parts = name.split(" ").filter(Boolean);
var s = (parts[0] ? parts[0][0] : email[0]) + (parts[1] ? parts[1][0] : "");
return s.toUpperCase();
}
function colorFor(email) {
var h = 0;
for (var i = 0; i < email.length; i++) h = (h * 31 + email.charCodeAt(i)) >>> 0;
return AVATAR_COLORS[h % AVATAR_COLORS.length];
}
function renderInvites() {
inviteList.innerHTML = "";
state.invites.forEach(function (email, idx) {
var li = document.createElement("li");
li.className = "invite-item";
var av = document.createElement("span");
av.className = "av";
av.style.background = colorFor(email);
av.textContent = initials(email);
var meta = document.createElement("span");
meta.className = "em";
meta.textContent = email;
var role = document.createElement("span");
role.className = "role";
role.textContent = idx === 0 ? "Admin" : "Member";
var rm = document.createElement("button");
rm.type = "button";
rm.className = "rm";
rm.setAttribute("aria-label", "Remove " + email);
rm.textContent = "×";
rm.addEventListener("click", function () {
state.invites.splice(idx, 1);
save(); renderInvites(); renderProgress();
toast("Removed " + email);
});
li.appendChild(av);
li.appendChild(meta);
li.appendChild(role);
li.appendChild(rm);
inviteList.appendChild(li);
});
inviteEmpty.hidden = state.invites.length > 0;
}
inviteForm.addEventListener("submit", function (e) {
e.preventDefault();
var v = inviteEmail.value.trim().toLowerCase();
if (!emailValid(v)) { setError(stagesEls[1], "inviteEmail", "Enter a valid email address."); return; }
if (state.invites.indexOf(v) !== -1) { setError(stagesEls[1], "inviteEmail", "That teammate is already invited."); return; }
setError(stagesEls[1], "inviteEmail", "");
state.invites.push(v);
inviteEmail.value = "";
save(); renderInvites(); renderProgress();
toast("Invite queued for " + v);
inviteEmail.focus();
});
inviteEmail.addEventListener("input", function () {
if (emailValid(inviteEmail.value.trim())) setError(stagesEls[1], "inviteEmail", "");
});
/* ---------- STEP 2: sources ---------- */
document.querySelectorAll(".source").forEach(function (btn) {
var name = btn.getAttribute("data-source");
function sync() {
var on = state.sources.indexOf(name) !== -1;
btn.classList.toggle("connected", on);
btn.setAttribute("aria-pressed", on ? "true" : "false");
btn.querySelector(".src-state").textContent = on ? "Connected" : "Connect";
}
btn.setAttribute("aria-pressed", "false");
sync();
btn.addEventListener("click", function () {
var i = state.sources.indexOf(name);
if (i === -1) { state.sources.push(name); toast(name + " connected"); }
else { state.sources.splice(i, 1); toast(name + " disconnected"); }
save(); sync(); renderProgress();
});
});
/* ---------- STEP 3: customize ---------- */
function applyAccent(hex) {
document.documentElement.style.setProperty("--brand", hex);
document.documentElement.style.setProperty("--brand-d", shade(hex, -16));
}
function shade(hex, pct) {
var n = parseInt(hex.slice(1), 16);
var r = (n >> 16) & 255, g = (n >> 8) & 255, b = n & 255;
var f = (pct + 100) / 100;
r = Math.max(0, Math.min(255, Math.round(r * f)));
g = Math.max(0, Math.min(255, Math.round(g * f)));
b = Math.max(0, Math.min(255, Math.round(b * f)));
return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
}
document.querySelectorAll("[data-accent]").forEach(function (sw) {
if (sw.getAttribute("data-accent") === state.accent) sw.setAttribute("aria-checked", "true");
sw.addEventListener("click", function () {
document.querySelectorAll("[data-accent]").forEach(function (s) { s.setAttribute("aria-checked", "false"); });
sw.setAttribute("aria-checked", "true");
state.accent = sw.getAttribute("data-accent");
applyAccent(state.accent);
save(); renderProgress();
});
});
document.querySelectorAll("[data-density]").forEach(function (btn) {
if (btn.getAttribute("data-density") === state.density) btn.setAttribute("aria-checked", "true");
btn.addEventListener("click", function () {
document.querySelectorAll("[data-density]").forEach(function (b) { b.setAttribute("aria-checked", "false"); });
btn.setAttribute("aria-checked", "true");
state.density = btn.getAttribute("data-density");
save(); renderProgress();
});
});
var digest = document.getElementById("weeklyDigest");
digest.checked = state.digest;
digest.addEventListener("change", function () {
state.digest = digest.checked;
save();
toast(digest.checked ? "Weekly digest on" : "Weekly digest off");
});
/* ---------- keyboard nav for radio-style groups ---------- */
document.querySelectorAll('[role="radiogroup"]').forEach(function (group) {
group.addEventListener("keydown", function (e) {
if (e.key !== "ArrowRight" && e.key !== "ArrowLeft" && e.key !== "ArrowDown" && e.key !== "ArrowUp") return;
var items = Array.prototype.slice.call(group.querySelectorAll('[role="radio"]'));
var idx = items.indexOf(document.activeElement);
if (idx === -1) idx = 0;
var dir = (e.key === "ArrowRight" || e.key === "ArrowDown") ? 1 : -1;
var next = (idx + dir + items.length) % items.length;
e.preventDefault();
items[next].focus();
items[next].click();
});
});
/* ---------- footer buttons ---------- */
backBtn.addEventListener("click", function () { if (state.step > 0) goTo(state.step - 1); });
nextBtn.addEventListener("click", function () {
if (!validateStep(state.step)) return;
if (state.step < TOTAL - 1) goTo(state.step + 1);
else finish();
});
skipBtn.addEventListener("click", function () {
if (state.step < TOTAL - 1) { toast("Skipped — you can finish this later"); goTo(state.step + 1); }
else finish();
});
/* ---------- step rail clicks ---------- */
document.querySelectorAll("[data-go]").forEach(function (b) {
b.addEventListener("click", function () { goTo(parseInt(b.getAttribute("data-go"), 10)); });
});
/* ---------- enter key advances on text steps ---------- */
document.getElementById("form0").addEventListener("submit", function (e) { e.preventDefault(); nextBtn.click(); });
document.getElementById("form3").addEventListener("submit", function (e) { e.preventDefault(); });
/* ---------- theme ---------- */
var themeToggle = document.getElementById("themeToggle");
function applyTheme(t) {
document.documentElement.setAttribute("data-theme", t);
themeToggle.setAttribute("aria-pressed", t === "dark" ? "true" : "false");
}
themeToggle.addEventListener("click", function () {
state.theme = state.theme === "dark" ? "light" : "dark";
applyTheme(state.theme);
save();
});
/* ---------- reset ---------- */
document.getElementById("resetBtn").addEventListener("click", function () {
if (!window.confirm("Reset all onboarding progress?")) return;
try { localStorage.removeItem(STORE_KEY); } catch (e) {}
state = clone(defaults);
location.reload();
});
/* ---------- done: summary + confetti ---------- */
function buildSummary() {
var bits = [];
bits.push("“" + (state.workspace.name || "Your workspace") + "” is live");
bits.push(state.invites.length + " teammate" + (state.invites.length === 1 ? "" : "s") + " invited");
bits.push(state.sources.length + " data source" + (state.sources.length === 1 ? "" : "s") + " connected");
document.getElementById("doneSummary").textContent = bits.join(" · ") + ".";
}
function launchConfetti() {
var host = document.getElementById("confetti");
if (!host) return;
host.innerHTML = "";
var colors = ["#6366f1", "#0ea5e9", "#10b981", "#f59e0b", "#ec4899"];
var reduce = window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
if (reduce) return;
for (var i = 0; i < 60; i++) {
var c = document.createElement("i");
c.style.left = Math.random() * 100 + "%";
c.style.background = colors[i % colors.length];
c.style.animationDuration = (1.8 + Math.random() * 1.6) + "s";
c.style.animationDelay = (Math.random() * 0.4) + "s";
c.style.transform = "rotate(" + (Math.random() * 360) + "deg)";
host.appendChild(c);
}
setTimeout(function () { host.innerHTML = ""; }, 4000);
}
document.getElementById("enterBtn").addEventListener("click", function () {
toast("Opening your dashboard…");
});
/* ---------- boot ---------- */
applyTheme(state.theme);
applyAccent(state.accent);
renderInvites();
if (state.finished) {
showStage("done");
eyebrow.textContent = "All done";
foot.hidden = true;
buildSummary();
} else {
goTo(Math.min(state.step, TOTAL - 1));
}
renderProgress();
})();<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Northwind — Onboarding</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<a class="skip-link" href="#main">Skip to content</a>
<div class="shell">
<!-- Sidebar / progress rail -->
<aside class="rail" aria-label="Onboarding progress">
<div class="brand">
<span class="logo" aria-hidden="true">
<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12l4-7h10l4 7-9 9z"/><path d="M9 12h6"/></svg>
</span>
<span class="brand-name">Northwind</span>
</div>
<div class="ring-wrap">
<svg class="ring" viewBox="0 0 120 120" role="img" aria-label="Overall setup progress">
<circle class="ring-track" cx="60" cy="60" r="52" />
<circle class="ring-fill" cx="60" cy="60" r="52" />
</svg>
<div class="ring-center">
<strong id="ringPct">0%</strong>
<span>complete</span>
</div>
</div>
<ol class="steps" id="steps">
<li class="step" data-step="0" aria-current="step">
<button type="button" class="step-btn" data-go="0">
<span class="step-mark" aria-hidden="true">1</span>
<span class="step-text">
<span class="step-title">Create workspace</span>
<span class="step-sub">Name your space</span>
</span>
</button>
</li>
<li class="step" data-step="1">
<button type="button" class="step-btn" data-go="1">
<span class="step-mark" aria-hidden="true">2</span>
<span class="step-text">
<span class="step-title">Invite team</span>
<span class="step-sub">Add collaborators</span>
</span>
</button>
</li>
<li class="step" data-step="2">
<button type="button" class="step-btn" data-go="2">
<span class="step-mark" aria-hidden="true">3</span>
<span class="step-text">
<span class="step-title">Connect data</span>
<span class="step-sub">Sync a source</span>
</span>
</button>
</li>
<li class="step" data-step="3">
<button type="button" class="step-btn" data-go="3">
<span class="step-mark" aria-hidden="true">4</span>
<span class="step-text">
<span class="step-title">Customize</span>
<span class="step-sub">Make it yours</span>
</span>
</button>
</li>
</ol>
<button type="button" class="reset-btn" id="resetBtn">Reset progress</button>
</aside>
<!-- Main panel -->
<main class="panel" id="main">
<header class="panel-head">
<p class="eyebrow" id="eyebrow">Step 1 of 4</p>
<button type="button" class="ghost theme-toggle" id="themeToggle" aria-pressed="false">
<span class="t-icon" aria-hidden="true">◐</span> Theme
</button>
</header>
<!-- STEP 0 -->
<section class="stage" data-stage="0" aria-label="Create workspace">
<h1 class="stage-title">Let's set up your workspace</h1>
<p class="stage-lead">This is where your team plans, ships, and tracks work together. You can change any of this later.</p>
<form class="form" id="form0" novalidate>
<label class="field">
<span class="field-label">Workspace name</span>
<input type="text" id="wsName" name="wsName" placeholder="Acme Robotics" autocomplete="organization" />
<span class="error" data-err="wsName"></span>
</label>
<label class="field">
<span class="field-label">Workspace URL</span>
<span class="url-input">
<span class="url-prefix">northwind.app/</span>
<input type="text" id="wsSlug" name="wsSlug" placeholder="acme-robotics" autocomplete="off" />
</span>
<span class="error" data-err="wsSlug"></span>
</label>
<fieldset class="field choice-set">
<legend class="field-label">What will you use Northwind for?</legend>
<div class="chips" role="radiogroup" aria-label="Primary use">
<button type="button" class="chip" role="radio" aria-checked="false" data-use="Product">Product</button>
<button type="button" class="chip" role="radio" aria-checked="false" data-use="Engineering">Engineering</button>
<button type="button" class="chip" role="radio" aria-checked="false" data-use="Marketing">Marketing</button>
<button type="button" class="chip" role="radio" aria-checked="false" data-use="Operations">Operations</button>
</div>
</fieldset>
</form>
</section>
<!-- STEP 1 -->
<section class="stage" data-stage="1" hidden aria-label="Invite team">
<h1 class="stage-title">Bring your team along</h1>
<p class="stage-lead">Onboarding is better together. Invite a few teammates — or skip and add them later.</p>
<form class="form" id="form1" novalidate>
<div class="invite-row">
<label class="field grow">
<span class="field-label">Email address</span>
<input type="email" id="inviteEmail" name="inviteEmail" placeholder="teammate@acme.com" autocomplete="off" />
<span class="error" data-err="inviteEmail"></span>
</label>
<button type="submit" class="primary add-invite">Add</button>
</div>
</form>
<ul class="invite-list" id="inviteList" aria-live="polite"></ul>
<p class="empty" id="inviteEmpty">No invites yet — add teammates above or skip for now.</p>
</section>
<!-- STEP 2 -->
<section class="stage" data-stage="2" hidden aria-label="Connect data">
<h1 class="stage-title">Connect a data source</h1>
<p class="stage-lead">Sync one source to unlock dashboards and insights. Pick any to continue.</p>
<div class="sources" id="sources" role="list">
<button type="button" class="source" role="listitem" data-source="GitHub">
<span class="src-ic gh" aria-hidden="true">⬡</span>
<span class="src-meta"><strong>GitHub</strong><small>Issues & PRs</small></span>
<span class="src-state">Connect</span>
</button>
<button type="button" class="source" role="listitem" data-source="Slack">
<span class="src-ic sl" aria-hidden="true">#</span>
<span class="src-meta"><strong>Slack</strong><small>Channels & alerts</small></span>
<span class="src-state">Connect</span>
</button>
<button type="button" class="source" role="listitem" data-source="Stripe">
<span class="src-ic st" aria-hidden="true">$</span>
<span class="src-meta"><strong>Stripe</strong><small>Revenue & MRR</small></span>
<span class="src-state">Connect</span>
</button>
<button type="button" class="source" role="listitem" data-source="PostgreSQL">
<span class="src-ic pg" aria-hidden="true">⛁</span>
<span class="src-meta"><strong>PostgreSQL</strong><small>Custom queries</small></span>
<span class="src-state">Connect</span>
</button>
</div>
</section>
<!-- STEP 3 -->
<section class="stage" data-stage="3" hidden aria-label="Customize">
<h1 class="stage-title">Make it yours</h1>
<p class="stage-lead">Pick an accent and a theme preference. You'll see it everywhere across Northwind.</p>
<form class="form" id="form3" novalidate>
<fieldset class="field choice-set">
<legend class="field-label">Accent color</legend>
<div class="swatches" role="radiogroup" aria-label="Accent color">
<button type="button" class="swatch" role="radio" aria-checked="false" data-accent="#6366f1" style="--sw:#6366f1" aria-label="Indigo"></button>
<button type="button" class="swatch" role="radio" aria-checked="false" data-accent="#0ea5e9" style="--sw:#0ea5e9" aria-label="Sky"></button>
<button type="button" class="swatch" role="radio" aria-checked="false" data-accent="#10b981" style="--sw:#10b981" aria-label="Emerald"></button>
<button type="button" class="swatch" role="radio" aria-checked="false" data-accent="#f59e0b" style="--sw:#f59e0b" aria-label="Amber"></button>
<button type="button" class="swatch" role="radio" aria-checked="false" data-accent="#ec4899" style="--sw:#ec4899" aria-label="Pink"></button>
</div>
</fieldset>
<fieldset class="field choice-set">
<legend class="field-label">Default view density</legend>
<div class="chips" role="radiogroup" aria-label="Density">
<button type="button" class="chip" role="radio" aria-checked="false" data-density="Comfortable">Comfortable</button>
<button type="button" class="chip" role="radio" aria-checked="false" data-density="Compact">Compact</button>
</div>
</fieldset>
<label class="switch-row">
<input type="checkbox" id="weeklyDigest" checked />
<span class="switch" aria-hidden="true"></span>
<span class="switch-text">
<strong>Weekly digest email</strong>
<small>A Monday recap of activity and metrics.</small>
</span>
</label>
</form>
</section>
<!-- DONE -->
<section class="stage done-stage" data-stage="done" hidden aria-label="Setup complete">
<div class="confetti" id="confetti" aria-hidden="true"></div>
<div class="done-badge" aria-hidden="true">
<svg viewBox="0 0 24 24" width="34" height="34" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6L9 17l-5-5"/></svg>
</div>
<h1 class="stage-title">You're all set! 🎉</h1>
<p class="stage-lead" id="doneSummary">Your workspace is ready to go.</p>
<button type="button" class="primary big" id="enterBtn">Enter Northwind</button>
</section>
<!-- Footer nav -->
<footer class="panel-foot" id="panelFoot">
<button type="button" class="ghost" id="backBtn">Back</button>
<div class="foot-right">
<button type="button" class="link" id="skipBtn">Skip for now</button>
<button type="button" class="primary" id="nextBtn">Continue</button>
</div>
</footer>
</main>
</div>
<div class="toast-host" id="toastHost" aria-live="polite" aria-atomic="true"></div>
<script src="script.js"></script>
</body>
</html>Onboarding Wizard
A polished setup flow for Northwind, a fictional SaaS product. A left rail pairs a numbered stepper with a circular progress ring that fills as each task is completed: create a workspace, invite your team, connect a data source, and customize the look. The main panel swaps in a focused form or choice screen for each step, with clear titles, helper copy, chips, color swatches, and a digest toggle.
Every interaction actually works. The workspace step auto-generates a URL slug from the name and validates required fields inline; invites are added with email validation, dedupe, generated avatars, and removable rows; data sources toggle a connected state; and the customize step live-updates the product accent color across the UI. Progress, theme, and all choices persist to localStorage, so a reload resumes exactly where you left off. Skip-for-now advances without blocking, the stepper lets you jump between steps, and finishing triggers a confetti celebration with a personalized summary.
The shell supports a working light/dark theme toggle, keyboard-navigable radio groups, focus-visible rings, ARIA roles and live regions, and a layout that collapses gracefully to a stacked mobile view down to ~360px.
Illustrative SaaS UI only — fictional product, metrics, and billing. No real backend.