Bootstrap 5 Page Header with Section Transitions
A portfolio page header with a pill navigation that wipes the background colour from the clicked point and slides in new content for each section.
<section class="wdw-stage">
<div class="container" style="max-width:1000px">
<header class="ph wdw-card overflow-hidden position-relative" id="pageHeader" data-section="bio">
<div class="ph-bg ph-bg-bio wdw-aurora is-active" aria-hidden="true"></div>
<div class="ph-bg ph-bg-projects" aria-hidden="true"></div>
<div class="ph-bg ph-bg-find wdw-aurora" aria-hidden="true"></div>
<div class="ph-inner position-relative p-4 p-md-5">
<div class="d-flex flex-column flex-sm-row align-items-sm-center justify-content-between gap-3 mb-5">
<span class="fw-bold d-inline-flex align-items-center gap-2">
<span class="ph-dot"></span>Mara Lindqvist
</span>
<nav aria-label="Page sections">
<div class="ph-tabs nav nav-pills rounded-pill p-1 gap-1" role="tablist">
<button class="nav-link rounded-pill active" id="tab-bio" role="tab" type="button" aria-selected="true" aria-controls="panel-bio" data-section="bio">Bio</button>
<button class="nav-link rounded-pill" id="tab-projects" role="tab" type="button" aria-selected="false" aria-controls="panel-projects" data-section="projects" tabindex="-1">Projects</button>
<button class="nav-link rounded-pill" id="tab-find" role="tab" type="button" aria-selected="false" aria-controls="panel-find" data-section="find" tabindex="-1">Find me</button>
</div>
</nav>
</div>
<div class="ph-panels">
<div class="ph-panel is-active" id="panel-bio" role="tabpanel" aria-labelledby="tab-bio">
<span class="ph-eyebrow">Bio</span>
<h1 class="display-4 fw-bolder mb-3">Hi, I’m Mara. I design calm, useful interfaces.</h1>
<p class="fs-5 ph-lead mb-4">Product designer based in Lisbon, ten years across fintech, health and open-source tools. I care about small details and fast load times.</p>
<div class="d-flex flex-wrap gap-2"><button type="button" class="btn ph-btn rounded-pill px-4" data-go="projects">See my work</button></div>
</div>
<div class="ph-panel" id="panel-projects" role="tabpanel" aria-labelledby="tab-projects" hidden>
<span class="ph-eyebrow">Projects</span>
<h1 class="display-4 fw-bolder mb-3">Three recent projects worth a look.</h1>
<ul class="list-unstyled fs-5 ph-lead mb-4 d-grid gap-2">
<li><strong>Ledgerly</strong> – a budgeting app redesign, +34% retention</li>
<li><strong>Pulse</strong> – a patient dashboard used in 40 clinics</li>
<li><strong>Trellis UI</strong> – an open-source component kit</li>
</ul>
<button type="button" class="btn ph-btn rounded-pill px-4" data-go="find">Get in touch</button>
</div>
<div class="ph-panel" id="panel-find" role="tabpanel" aria-labelledby="tab-find" hidden>
<span class="ph-eyebrow">Find me</span>
<h1 class="display-4 fw-bolder mb-3">Let’s talk about your next project.</h1>
<p class="fs-5 ph-lead mb-4">Currently booking for spring. The fastest way to reach me is a short email with a few lines about what you’re building.</p>
<div class="d-flex flex-wrap gap-2"><a class="btn ph-btn rounded-pill px-4" href="#">[email protected]</a><a class="btn ph-btn-ghost rounded-pill px-4" href="#">Book a call</a></div>
</div>
</div>
<div class="ph-foot d-flex align-items-center gap-3 mt-5" aria-hidden="true">
<span class="ph-step fw-bold" id="phStep">01 / 03</span>
<span class="ph-bars d-flex gap-1" id="phBars"><i class="on"></i><i></i><i></i></span>
<span class="ph-next ms-auto small fw-semibold" id="phNext">Next: Projects →</span>
</div>
</div>
</header>
</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 */
.ph { min-height: 520px; --ph-fg: #fff; --ph-fg-soft: rgba(255,255,255,.78); --ph-ctl-bg: #fff; --ph-ctl-fg: #1e1b4b; color: var(--ph-fg); transition: color .5s; }
.ph[data-section="projects"] { --ph-fg: var(--bs-emphasis-color); --ph-fg-soft: var(--bs-secondary-color); --ph-ctl-bg: var(--bs-primary); --ph-ctl-fg: #fff; }
[data-bs-theme="dark"] .ph[data-section="projects"] { --ph-ctl-fg: #0f1117; }
.ph-bg { position: absolute; inset: 0; clip-path: circle(0 at var(--x, 50%) var(--y, 0%)); z-index: 0; }
.ph-bg.is-active { clip-path: circle(150% at var(--x, 50%) var(--y, 0%)); }
.ph-bg.is-entering { transition: clip-path .7s cubic-bezier(.65,0,.2,1); }
.ph-bg-projects { background: linear-gradient(var(--bs-primary-bg-subtle), var(--bs-primary-bg-subtle)), var(--bs-body-bg); }
.ph-bg-find::after { content: ""; position: absolute; inset: 0; background: rgba(8,6,28,.62); }
.ph-inner { z-index: 2; }
.ph-lead { color: var(--ph-fg-soft); max-width: 40rem; transition: color .5s; }
.ph h1 { letter-spacing: -.03em; max-width: 44rem; }
.ph-dot { width: .75rem; height: .75rem; border-radius: 50%; background: currentColor; }
.ph-eyebrow { display: inline-block; font-size: .75rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 1rem; padding: .3rem .75rem; border-radius: 99px; background: color-mix(in srgb, var(--ph-fg) 12%, transparent); }
.ph-tabs { background: color-mix(in srgb, var(--ph-fg) 10%, transparent); width: fit-content; }
.ph-tabs .nav-link { --bs-nav-link-color: var(--ph-fg-soft); --bs-nav-link-hover-color: var(--ph-fg); min-height: 40px; font-weight: 600; padding-inline: 1.1rem; transition: background .25s, color .25s; }
.ph-tabs .nav-link.active { background: var(--ph-ctl-bg); color: var(--ph-ctl-fg); }
.ph-tabs .nav-link:focus-visible { box-shadow: 0 0 0 .2rem rgba(255,255,255,.5); outline: 0; }
.ph[data-section="projects"] .ph-tabs .nav-link:focus-visible { box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }
.ph-btn { background: var(--ph-ctl-bg); color: var(--ph-ctl-fg); border: 0; }
.ph-btn:hover { background: var(--ph-ctl-bg); color: var(--ph-ctl-fg); opacity: .88; }
.ph-btn-ghost { color: var(--ph-fg); border: 1px solid color-mix(in srgb, var(--ph-fg) 45%, transparent); }
.ph-btn-ghost:hover { color: var(--ph-fg); background: color-mix(in srgb, var(--ph-fg) 12%, transparent); }
.ph-panel.is-active { animation: ph-in .55s .15s both cubic-bezier(.2,.7,.2,1); }
@keyframes ph-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (max-width: 575.98px) { .ph h1 { font-size: 2rem; } .ph { min-height: 0; } }
@media (prefers-reduced-motion: reduce) { .ph-bg.is-entering, .ph-panel.is-active { transition: none; animation: none; } }
.ph-foot { color: var(--ph-fg-soft); font-variant-numeric: tabular-nums; }
.ph-step { color: var(--ph-fg); letter-spacing: .05em; }
.ph-bars i { display: block; width: 28px; height: 4px; border-radius: 4px; background: color-mix(in srgb, var(--ph-fg) 25%, transparent); transition: background .4s, width .4s; }
.ph-bars i.on { width: 44px; background: var(--ph-fg); }
(function () {
function initPageHeader() {
const header = document.getElementById('pageHeader');
if (!header) return;
const tabs = header.querySelectorAll('[role="tab"]');
const panels = header.querySelectorAll('.ph-panel');
const bgs = { bio: '.ph-bg-bio', projects: '.ph-bg-projects', find: '.ph-bg-find' };
const order = ['bio', 'projects', 'find'];
const labels = { bio: 'Bio', projects: 'Projects', find: 'Find me' };
const step = header.querySelector('#phStep');
const bars = header.querySelectorAll('#phBars i');
const nextHint = header.querySelector('#phNext');
const allBgs = Object.values(bgs).map(s => header.querySelector(s));
let current = 'bio';
let timer = 0;
let z = 1;
function show(name, origin) {
if (name === current) return;
const next = header.querySelector(bgs[name]);
const prev = header.querySelector(bgs[current]);
const r = header.getBoundingClientRect();
const x = origin ? ((origin.x - r.left) / r.width) * 100 : 50;
const y = origin ? ((origin.y - r.top) / r.height) * 100 : 0;
next.style.setProperty('--x', x + '%');
next.style.setProperty('--y', y + '%');
clearTimeout(timer);
// hide every layer that is not the one being replaced or the incoming one
allBgs.forEach(bg => { if (bg !== next && bg !== prev) bg.classList.remove('is-active', 'is-entering'); });
// reset the incoming layer instantly, then wipe it in from the click point on top
next.classList.remove('is-entering', 'is-active');
void next.offsetWidth;
next.style.zIndex = ++z;
next.classList.add('is-entering');
void next.offsetWidth;
next.classList.add('is-active');
// only strip layers that are not the current section
timer = setTimeout(() => {
allBgs.forEach(bg => { if (bg !== next) bg.classList.remove('is-active'); bg.classList.remove('is-entering'); });
}, 720);
header.dataset.section = name;
tabs.forEach(t => {
const on = t.dataset.section === name;
t.classList.toggle('active', on);
t.setAttribute('aria-selected', on);
t.tabIndex = on ? 0 : -1;
});
panels.forEach(p => {
const on = p.id === 'panel-' + name;
p.hidden = !on;
p.classList.toggle('is-active', on);
});
current = name;
const i = order.indexOf(name);
step.textContent = '0' + (i + 1) + ' / 03';
bars.forEach((bar, k) => bar.classList.toggle('on', k === i));
nextHint.textContent = 'Next: ' + labels[order[(i + 1) % order.length]] + ' \u2192';
}
tabs.forEach((t, i) => {
t.addEventListener('click', e => {
const b = t.getBoundingClientRect();
show(t.dataset.section, { x: b.left + b.width / 2, y: b.top + b.height / 2 });
});
t.addEventListener('keydown', e => {
if (e.key !== 'ArrowRight' && e.key !== 'ArrowLeft') return;
const n = tabs[(i + (e.key === 'ArrowRight' ? 1 : tabs.length - 1)) % tabs.length];
n.focus(); n.click();
});
});
header.querySelectorAll('[data-go]').forEach(b => b.addEventListener('click', () => {
const r = b.getBoundingClientRect();
show(b.dataset.go, { x: r.left + r.width / 2, y: r.top + r.height / 2 });
}));
}
initPageHeader();
})();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.