Snippets Buttons

Bootstrap 5 Segmented Control with Sliding Indicator

A pill-shaped segmented control with a sliding highlight that switches between Music, Movies and Apps lists.

Bootstrap 5 No jQuery Feb 2020 4.2K views

<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>

Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.