Bootstrap 5 Segmented Control with Sliding Indicator
A pill-shaped segmented control with a sliding highlight that switches between Music, Movies and Apps lists.
<section class="wdw-stage">
<div class="container sg-container">
<div class="wdw-aurora rounded-5 p-4 p-md-5 sg-hero">
<div class="text-center mb-4 position-relative">
<span class="wdw-eyebrow sg-eyebrow">Library</span>
<h2 class="wdw-heading sg-title h2 mt-1 mb-0">Browse by category</h2>
</div>
<div class="d-flex justify-content-center mb-4 position-relative">
<ul class="nav nav-pills rounded-pill sg" id="sgTabs" role="tablist" aria-label="Library categories">
<li class="sg-thumb" role="presentation" aria-hidden="true"></li>
<li class="nav-item" role="presentation"><button class="nav-link rounded-pill active" id="sg-tab-0" data-bs-toggle="pill" data-bs-target="#sg-panel-0" type="button" role="tab" aria-controls="sg-panel-0" aria-selected="true">Music</button></li><li class="nav-item" role="presentation"><button class="nav-link rounded-pill" id="sg-tab-1" data-bs-toggle="pill" data-bs-target="#sg-panel-1" type="button" role="tab" aria-controls="sg-panel-1" aria-selected="false">Movies</button></li><li class="nav-item" role="presentation"><button class="nav-link rounded-pill" id="sg-tab-2" data-bs-toggle="pill" data-bs-target="#sg-panel-2" type="button" role="tab" aria-controls="sg-panel-2" aria-selected="false">Apps</button></li>
</ul>
</div>
<div class="wdw-card px-3 px-md-4 py-2 position-relative">
<div class="tab-content">
<div class="tab-pane fade show active" id="sg-panel-0" role="tabpanel" aria-labelledby="sg-tab-0" tabindex="0"><ul class="list-unstyled mb-0 sg-list"><li class="d-flex align-items-center gap-3 py-3"><img class="sg-art rounded-3" src="https://images.unsplash.com/photo-1519681393784-d120267933ba?w=160&q=75&fm=jpg" alt="" width="56" height="56" loading="lazy"><div class="flex-grow-1 min-w-0"><div class="fw-semibold text-body-emphasis text-truncate">Midnight Drive</div><div class="small wdw-muted text-truncate">Neon Harbor · Synthwave</div></div><span class="small wdw-muted d-none d-sm-inline">3:42</span><button type="button" class="btn btn-primary btn-sm rounded-circle sg-round p-0" aria-label="Play Midnight Drive"><svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M8 5v14l11-7z"/></svg></button></li><li class="d-flex align-items-center gap-3 py-3"><img class="sg-art rounded-3" src="https://images.unsplash.com/photo-1497733942558-e74c87ef89db?w=160&q=75&fm=jpg" alt="" width="56" height="56" loading="lazy"><div class="flex-grow-1 min-w-0"><div class="fw-semibold text-body-emphasis text-truncate">Paper Planes</div><div class="small wdw-muted text-truncate">The Quiet Hours · Indie</div></div><span class="small wdw-muted d-none d-sm-inline">4:05</span><button type="button" class="btn btn-primary btn-sm rounded-circle sg-round p-0" aria-label="Play Paper Planes"><svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M8 5v14l11-7z"/></svg></button></li><li class="d-flex align-items-center gap-3 py-3"><img class="sg-art rounded-3" src="https://images.unsplash.com/photo-1540744276164-9dc898353c7b?w=160&q=75&fm=jpg" alt="" width="56" height="56" loading="lazy"><div class="flex-grow-1 min-w-0"><div class="fw-semibold text-body-emphasis text-truncate">Low Tide</div><div class="small wdw-muted text-truncate">Marlo Reyes · Ambient</div></div><span class="small wdw-muted d-none d-sm-inline">5:18</span><button type="button" class="btn btn-primary btn-sm rounded-circle sg-round p-0" aria-label="Play Low Tide"><svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M8 5v14l11-7z"/></svg></button></li><li class="d-flex align-items-center gap-3 py-3"><img class="sg-art rounded-3" src="https://images.unsplash.com/photo-1469975692758-66d107a536cb?w=160&q=75&fm=jpg" alt="" width="56" height="56" loading="lazy"><div class="flex-grow-1 min-w-0"><div class="fw-semibold text-body-emphasis text-truncate">Golden Hour</div><div class="small wdw-muted text-truncate">Skyline Club · Electronic</div></div><span class="small wdw-muted d-none d-sm-inline">3:27</span><button type="button" class="btn btn-primary btn-sm rounded-circle sg-round p-0" aria-label="Play Golden Hour"><svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M8 5v14l11-7z"/></svg></button></li></ul></div><div class="tab-pane fade" id="sg-panel-1" role="tabpanel" aria-labelledby="sg-tab-1" tabindex="0"><ul class="list-unstyled mb-0 sg-list"><li class="d-flex align-items-center gap-3 py-3"><img class="sg-poster rounded-3" src="https://images.unsplash.com/photo-1541673504494-8bcc1a340180?w=160&q=75&fm=jpg" alt="" width="48" height="64" loading="lazy"><div class="flex-grow-1 min-w-0"><div class="fw-semibold text-body-emphasis text-truncate">The Last Lighthouse</div><div class="small wdw-muted text-truncate">Drama · 2h 04m</div></div><span class="badge rounded-pill bg-warning-subtle text-warning-emphasis">★ 8.1</span><span class="wdw-muted d-none d-sm-inline"><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="m9 6 6 6-6 6"/></svg></span></li><li class="d-flex align-items-center gap-3 py-3"><img class="sg-poster rounded-3" src="https://images.unsplash.com/photo-1540744276164-9dc898353c7b?w=160&q=75&fm=jpg" alt="" width="48" height="64" loading="lazy"><div class="flex-grow-1 min-w-0"><div class="fw-semibold text-body-emphasis text-truncate">Orbit Seven</div><div class="small wdw-muted text-truncate">Sci-fi · 1h 52m</div></div><span class="badge rounded-pill bg-warning-subtle text-warning-emphasis">★ 7.6</span><span class="wdw-muted d-none d-sm-inline"><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="m9 6 6 6-6 6"/></svg></span></li><li class="d-flex align-items-center gap-3 py-3"><img class="sg-poster rounded-3" src="https://images.unsplash.com/photo-1515937350506-3e7b51a95339?w=160&q=75&fm=jpg" alt="" width="48" height="64" loading="lazy"><div class="flex-grow-1 min-w-0"><div class="fw-semibold text-body-emphasis text-truncate">Quiet Streets</div><div class="small wdw-muted text-truncate">Documentary · 1h 31m</div></div><span class="badge rounded-pill bg-warning-subtle text-warning-emphasis">★ 8.4</span><span class="wdw-muted d-none d-sm-inline"><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="m9 6 6 6-6 6"/></svg></span></li><li class="d-flex align-items-center gap-3 py-3"><img class="sg-poster rounded-3" src="https://images.unsplash.com/photo-1469975692758-66d107a536cb?w=160&q=75&fm=jpg" alt="" width="48" height="64" loading="lazy"><div class="flex-grow-1 min-w-0"><div class="fw-semibold text-body-emphasis text-truncate">Salt & Sand</div><div class="small wdw-muted text-truncate">Adventure · 1h 47m</div></div><span class="badge rounded-pill bg-warning-subtle text-warning-emphasis">★ 7.9</span><span class="wdw-muted d-none d-sm-inline"><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="m9 6 6 6-6 6"/></svg></span></li></ul></div><div class="tab-pane fade" id="sg-panel-2" role="tabpanel" aria-labelledby="sg-tab-2" tabindex="0"><ul class="list-unstyled mb-0 sg-list"><li class="d-flex align-items-center gap-3 py-3"><span class="wdw-icon sg-app"><svg width="26" height="26" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="7" height="7" rx="1.5"/><rect x="14" y="3" width="7" height="7" rx="1.5"/><rect x="3" y="14" width="7" height="7" rx="1.5"/><rect x="14" y="14" width="7" height="7" rx="1.5"/></svg></span><div class="flex-grow-1 min-w-0"><div class="fw-semibold text-body-emphasis text-truncate">Focus Timer</div><div class="small wdw-muted text-truncate">Productivity · 4.8 ★</div></div><button type="button" class="btn btn-outline-primary btn-sm rounded-pill px-3" aria-label="Get Focus Timer">Get</button></li><li class="d-flex align-items-center gap-3 py-3"><span class="wdw-icon sg-app"><svg width="26" height="26" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"/><path d="M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z"/></svg></span><div class="flex-grow-1 min-w-0"><div class="fw-semibold text-body-emphasis text-truncate">Sketchpad</div><div class="small wdw-muted text-truncate">Design · 4.6 ★</div></div><button type="button" class="btn btn-outline-primary btn-sm rounded-pill px-3" aria-label="$2.99 Sketchpad">$2.99</button></li><li class="d-flex align-items-center gap-3 py-3"><span class="wdw-icon sg-app"><svg width="26" height="26" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="m15.5 8.5-2 5-5 2 2-5Z"/></svg></span><div class="flex-grow-1 min-w-0"><div class="fw-semibold text-body-emphasis text-truncate">Trailhead</div><div class="small wdw-muted text-truncate">Travel · 4.7 ★</div></div><button type="button" class="btn btn-outline-primary btn-sm rounded-pill px-3" aria-label="Get Trailhead">Get</button></li><li class="d-flex align-items-center gap-3 py-3"><span class="wdw-icon sg-app"><svg width="26" height="26" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="6" width="18" height="13" rx="2"/><path d="M3 10h18"/></svg></span><div class="flex-grow-1 min-w-0"><div class="fw-semibold text-body-emphasis text-truncate">Ledger</div><div class="small wdw-muted text-truncate">Finance · 4.5 ★</div></div><button type="button" class="btn btn-outline-primary btn-sm rounded-pill px-3" aria-label="Get Ledger">Get</button></li></ul></div>
</div>
</div>
</div>
</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 */
.sg-container { max-width: 760px; }
.sg-eyebrow { color: #c7d2fe; }
.sg-title { color: #fff; }
.sg { position: relative; display: inline-flex; flex-wrap: nowrap; padding: .3rem; background: var(--bs-tertiary-bg); border: 1px solid var(--bs-border-color); max-width: 100%; }
.sg .nav-link { position: relative; z-index: 1; min-height: 44px; min-width: 6rem; padding: 0 1.5rem; font-weight: 600; background: transparent; color: var(--bs-secondary-color); transition: color .25s; }
.sg .nav-link:hover { color: var(--bs-emphasis-color); }
.sg .nav-link.active { background: transparent; color: var(--bs-primary-text-emphasis); }
.sg-thumb { position: absolute; z-index: 0; top: .3rem; bottom: .3rem; left: 0; width: var(--sg-w, 0); transform: translateX(var(--sg-x, 0)); border-radius: 999px; background: var(--bs-body-bg); box-shadow: var(--wdw-shadow-sm); transition: transform .35s cubic-bezier(.3,1.2,.4,1), width .35s cubic-bezier(.3,1.2,.4,1); }
.sg-list > li + li { border-top: 1px solid var(--bs-border-color-translucent); }
.sg-art { width: 3.5rem; height: 3.5rem; object-fit: cover; flex: none; }
.sg-poster { width: 3rem; height: 4rem; object-fit: cover; flex: none; }
.sg-app { width: 3.5rem; height: 3.5rem; border-radius: 1rem; }
.sg-round { width: 2.5rem; height: 2.5rem; min-height: 0; flex: none; }
.min-w-0 { min-width: 0; }
.tab-pane:focus-visible { outline: 3px solid var(--bs-focus-ring-color); border-radius: 1rem; }
@media (max-width: 420px) { .sg .nav-link { min-width: 0; padding: 0 1rem; } }
@media (prefers-reduced-motion: reduce) { .sg-thumb { transition: none; } .sg .nav-link { transition: none; } }
(function () {
function initSegmented() {
var root = document.getElementById('sgTabs');
if (!root) return;
var thumb = root.querySelector('.sg-thumb');
if (!thumb) return;
function place() {
var btn = root.querySelector('.nav-link.active');
if (!btn) return;
root.style.setProperty('--sg-x', btn.parentElement.offsetLeft + 'px');
root.style.setProperty('--sg-w', btn.parentElement.offsetWidth + 'px');
}
thumb.style.transition = 'none';
place();
requestAnimationFrame(function () { thumb.style.transition = ''; });
root.addEventListener('shown.bs.tab', place);
window.addEventListener('resize', place);
if (document.fonts && document.fonts.ready) document.fonts.ready.then(place);
}
initSegmented();
})();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.