Snippets Tabs

Bootstrap 5 Tab Styles (4 Modern Designs)

Four Bootstrap 5 tab designs: a segmented control with a sliding indicator, underline tabs with counters, icon pills and a vertical settings sidebar. Each switches real panels using Bootstrap's tab component, so arrow-key and screen reader behaviour comes built in.

Bootstrap 5 No jQuery Sep 2019 1.8K views

<section class="wdw-stage tb-stage"><div class="container" style="max-width:960px;">
<div class="text-center mb-5"><span class="wdw-eyebrow mb-3">Tabs</span>
<h1 class="h2 wdw-heading mb-2">Tab styles</h1><p class="text-body-secondary mb-0">Four tab designs built on Bootstrap's tab plugin. Arrow keys move between tabs.</p></div>
<div class="row g-3 g-md-4">
<div class="col-md-6"><div class="card wdw-card-sm h-100"><div class="card-body p-4"><div class="mb-3"><p class="fw-semibold text-body-emphasis mb-0">Segmented</p><p class="small text-body-secondary mb-0">Sliding indicator</p></div><ul class="nav tb-segment p-1 rounded-pill bg-body-secondary d-inline-flex position-relative" role="tablist"><span class="tb-slider" aria-hidden="true"></span><li class="nav-item" role="presentation"><button class="nav-link active" id="t1-0-tab" data-bs-toggle="tab" data-bs-target="#t1-0" type="button" role="tab" aria-controls="t1-0" aria-selected="true"><span>Overview</span></button></li><li class="nav-item" role="presentation"><button class="nav-link" id="t1-1-tab" data-bs-toggle="tab" data-bs-target="#t1-1" type="button" role="tab" aria-controls="t1-1" aria-selected="false"><span>Activity</span></button></li><li class="nav-item" role="presentation"><button class="nav-link" id="t1-2-tab" data-bs-toggle="tab" data-bs-target="#t1-2" type="button" role="tab" aria-controls="t1-2" aria-selected="false"><span>Settings</span></button></li></ul><div class="tab-content tb-body pt-3"><div class="tab-pane fade show active" id="t1-0" role="tabpanel" aria-labelledby="t1-0-tab" tabindex="0"><div class="row g-2"><div class="col-12"><h3 class="h6 fw-semibold text-body-emphasis mb-2">Project Atlas</h3></div><div class="col-4"><div class="rounded-3 bg-body-tertiary p-2 p-sm-3 h-100"><div class="fs-5 fw-bold text-body-emphasis lh-1">12.4k</div><div class="small text-body-secondary mt-1">Visitors</div><div class="small text-success fw-medium">+8.2%</div></div></div><div class="col-4"><div class="rounded-3 bg-body-tertiary p-2 p-sm-3 h-100"><div class="fs-5 fw-bold text-body-emphasis lh-1">3.1%</div><div class="small text-body-secondary mt-1">Conversion</div><div class="small text-success fw-medium">+0.4%</div></div></div><div class="col-4"><div class="rounded-3 bg-body-tertiary p-2 p-sm-3 h-100"><div class="fs-5 fw-bold text-body-emphasis lh-1">$9.2k</div><div class="small text-body-secondary mt-1">Revenue</div><div class="small text-success fw-medium">+12%</div></div></div></div></div><div class="tab-pane fade" id="t1-1" role="tabpanel" aria-labelledby="t1-1-tab" tabindex="0"><ul class="list-unstyled mb-0 small"><li class="d-flex align-items-start gap-3 py-2"><span class="tb-av rounded-circle d-inline-flex align-items-center justify-content-center fw-semibold">M</span><span class="flex-grow-1 small"><strong class="text-body-emphasis">Maya</strong> <span class="text-body-secondary">merged the pricing page</span></span><span class="small text-body-secondary text-nowrap">2m</span></li><li class="d-flex align-items-start gap-3 py-2"><span class="tb-av rounded-circle d-inline-flex align-items-center justify-content-center fw-semibold">J</span><span class="flex-grow-1 small"><strong class="text-body-emphasis">Jonas</strong> <span class="text-body-secondary">commented on design review</span></span><span class="small text-body-secondary text-nowrap">1h</span></li><li class="d-flex align-items-start gap-3 py-2"><span class="tb-av rounded-circle d-inline-flex align-items-center justify-content-center fw-semibold">P</span><span class="flex-grow-1 small"><strong class="text-body-emphasis">Priya</strong> <span class="text-body-secondary">deployed v2.4.0</span></span><span class="small text-body-secondary text-nowrap">3h</span></li></ul></div><div class="tab-pane fade" id="t1-2" role="tabpanel" aria-labelledby="t1-2-tab" tabindex="0"><h3 class="h6 fw-semibold text-body-emphasis mb-2">Project name</h3><div class="input-group"><input type="text" class="form-control" value="Atlas" aria-label="Project name"><button class="btn btn-primary" type="button">Save</button></div></div></div></div></div></div>
<div class="col-md-6"><div class="card wdw-card-sm h-100"><div class="card-body p-4"><div class="mb-3"><p class="fw-semibold text-body-emphasis mb-0">Underline with counts</p><p class="small text-body-secondary mb-0">Badge counters</p></div><ul class="nav tb-underline border-bottom gap-3" role="tablist"><li class="nav-item" role="presentation"><button class="nav-link active" id="t2-0-tab" data-bs-toggle="tab" data-bs-target="#t2-0" type="button" role="tab" aria-controls="t2-0" aria-selected="true"><span>Inbox</span><span class="badge rounded-pill tb-count">4</span></button></li><li class="nav-item" role="presentation"><button class="nav-link" id="t2-1-tab" data-bs-toggle="tab" data-bs-target="#t2-1" type="button" role="tab" aria-controls="t2-1" aria-selected="false"><span>Drafts</span><span class="badge rounded-pill tb-count">2</span></button></li><li class="nav-item" role="presentation"><button class="nav-link" id="t2-2-tab" data-bs-toggle="tab" data-bs-target="#t2-2" type="button" role="tab" aria-controls="t2-2" aria-selected="false"><span>Sent</span></button></li></ul><div class="tab-content tb-body pt-3"><div class="tab-pane fade show active" id="t2-0" role="tabpanel" aria-labelledby="t2-0-tab" tabindex="0"><ul class="list-unstyled mb-0"><li class="d-flex align-items-start gap-3 py-2"><span class="tb-av rounded-circle d-inline-flex align-items-center justify-content-center fw-semibold">A</span><span class="flex-grow-1 small"><strong class="text-body-emphasis">Acme</strong> <span class="text-body-secondary">Invoice #1042 is ready</span></span><span class="small text-body-secondary text-nowrap">9:41</span></li><li class="d-flex align-items-start gap-3 py-2"><span class="tb-av rounded-circle d-inline-flex align-items-center justify-content-center fw-semibold">S</span><span class="flex-grow-1 small"><strong class="text-body-emphasis">Stripe</strong> <span class="text-body-secondary">Payout of $1,280 sent</span></span><span class="small text-body-secondary text-nowrap">8:15</span></li><li class="d-flex align-items-start gap-3 py-2"><span class="tb-av rounded-circle d-inline-flex align-items-center justify-content-center fw-semibold">L</span><span class="flex-grow-1 small"><strong class="text-body-emphasis">Linear</strong> <span class="text-body-secondary">3 issues assigned to you</span></span><span class="small text-body-secondary text-nowrap">Mon</span></li></ul></div><div class="tab-pane fade" id="t2-1" role="tabpanel" aria-labelledby="t2-1-tab" tabindex="0"><ul class="list-unstyled mb-0"><li class="d-flex align-items-start gap-3 py-2"><span class="tb-av rounded-circle d-inline-flex align-items-center justify-content-center fw-semibold">Y</span><span class="flex-grow-1 small"><strong class="text-body-emphasis">You</strong> <span class="text-body-secondary">Q4 roadmap announcement</span></span><span class="small text-body-secondary text-nowrap">Draft</span></li><li class="d-flex align-items-start gap-3 py-2"><span class="tb-av rounded-circle d-inline-flex align-items-center justify-content-center fw-semibold">Y</span><span class="flex-grow-1 small"><strong class="text-body-emphasis">You</strong> <span class="text-body-secondary">Welcome email, v3</span></span><span class="small text-body-secondary text-nowrap">Draft</span></li></ul></div><div class="tab-pane fade" id="t2-2" role="tabpanel" aria-labelledby="t2-2-tab" tabindex="0"><ul class="list-unstyled mb-0"><li class="d-flex align-items-start gap-3 py-2"><span class="tb-av rounded-circle d-inline-flex align-items-center justify-content-center fw-semibold">Y</span><span class="flex-grow-1 small"><strong class="text-body-emphasis">You</strong> <span class="text-body-secondary">Re: Contract renewal</span></span><span class="small text-body-secondary text-nowrap">Fri</span></li><li class="d-flex align-items-start gap-3 py-2"><span class="tb-av rounded-circle d-inline-flex align-items-center justify-content-center fw-semibold">Y</span><span class="flex-grow-1 small"><strong class="text-body-emphasis">You</strong> <span class="text-body-secondary">Design handoff notes</span></span><span class="small text-body-secondary text-nowrap">Thu</span></li><li class="d-flex align-items-start gap-3 py-2"><span class="tb-av rounded-circle d-inline-flex align-items-center justify-content-center fw-semibold">Y</span><span class="flex-grow-1 small"><strong class="text-body-emphasis">You</strong> <span class="text-body-secondary">Weekly update</span></span><span class="small text-body-secondary text-nowrap">Wed</span></li></ul></div></div></div></div></div>
<div class="col-md-6"><div class="card wdw-card-sm h-100"><div class="card-body p-4"><div class="mb-3"><p class="fw-semibold text-body-emphasis mb-0">Icon pills</p><p class="small text-body-secondary mb-0">Icon and label</p></div><ul class="nav nav-pills gap-2 tb-pills flex-nowrap overflow-x-auto" role="tablist"><li class="nav-item" role="presentation"><button class="nav-link active" id="t3-0-tab" data-bs-toggle="tab" data-bs-target="#t3-0" type="button" role="tab" aria-controls="t3-0" aria-selected="true"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg><span>Profile</span></button></li><li class="nav-item" role="presentation"><button class="nav-link" id="t3-1-tab" data-bs-toggle="tab" data-bs-target="#t3-1" type="button" role="tab" aria-controls="t3-1" aria-selected="false"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/></svg><span>Alerts</span></button></li><li class="nav-item" role="presentation"><button class="nav-link" id="t3-2-tab" data-bs-toggle="tab" data-bs-target="#t3-2" type="button" role="tab" aria-controls="t3-2" aria-selected="false"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="20" height="14" x="2" y="5" rx="2"/><path d="M2 10h20"/></svg><span>Billing</span></button></li></ul><div class="tab-content tb-body pt-3"><div class="tab-pane fade show active" id="t3-0" role="tabpanel" aria-labelledby="t3-0-tab" tabindex="0"><div class="row g-2"><div class="col-6"><label class="form-label small text-body-secondary mb-1" for="tb3a">First name</label><input id="tb3a" class="form-control" value="Maya"></div><div class="col-6"><label class="form-label small text-body-secondary mb-1" for="tb3b">Last name</label><input id="tb3b" class="form-control" value="Fischer"></div><div class="col-12"><label class="form-label small text-body-secondary mb-1" for="tb3e">Email</label><input id="tb3e" type="email" class="form-control" value="[email protected]"></div></div></div><div class="tab-pane fade" id="t3-1" role="tabpanel" aria-labelledby="t3-1-tab" tabindex="0"><div class="form-check form-switch mb-2"><input class="form-check-input" type="checkbox" role="switch" id="tb3c" checked><label class="form-check-label" for="tb3c">Email me about new comments</label></div><div class="form-check form-switch"><input class="form-check-input" type="checkbox" role="switch" id="tb3d"><label class="form-check-label" for="tb3d">Weekly digest</label></div><div class="form-check form-switch mt-2"><input class="form-check-input" type="checkbox" role="switch" id="tb3f" checked><label class="form-check-label" for="tb3f">Product updates</label></div></div><div class="tab-pane fade" id="t3-2" role="tabpanel" aria-labelledby="t3-2-tab" tabindex="0"><div class="d-flex align-items-center justify-content-between rounded-3 border p-3"><div><div class="fw-semibold text-body-emphasis">Pro plan</div><div class="small text-body-secondary">Renews on Nov 12</div></div><span class="fw-bold text-body-emphasis">$24<small class="text-body-secondary fw-normal">/mo</small></span></div><p class="small text-body-secondary mt-3 mb-0">Visa ending 4242. Invoices are emailed to [email protected].</p></div></div></div></div></div>
<div class="col-md-6"><div class="card wdw-card-sm h-100"><div class="card-body p-4"><div class="mb-3"><p class="fw-semibold text-body-emphasis mb-0">Vertical</p><p class="small text-body-secondary mb-0">Settings sidebar</p></div><div class="d-flex flex-column flex-sm-row gap-3"><ul class="nav nav-pills flex-nowrap overflow-x-auto flex-sm-column tb-vert gap-1 flex-shrink-0" role="tablist" aria-orientation="vertical"><li class="nav-item" role="presentation"><button class="nav-link active" id="t4-0-tab" data-bs-toggle="tab" data-bs-target="#t4-0" type="button" role="tab" aria-controls="t4-0" aria-selected="true"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="7" height="7" x="3" y="3" rx="1"/><rect width="7" height="7" x="14" y="3" rx="1"/><rect width="7" height="7" x="14" y="14" rx="1"/><rect width="7" height="7" x="3" y="14" rx="1"/></svg><span>General</span></button></li><li class="nav-item" role="presentation"><button class="nav-link" id="t4-1-tab" data-bs-toggle="tab" data-bs-target="#t4-1" type="button" role="tab" aria-controls="t4-1" aria-selected="false"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg><span>Members</span></button></li><li class="nav-item" role="presentation"><button class="nav-link" id="t4-2-tab" data-bs-toggle="tab" data-bs-target="#t4-2" type="button" role="tab" aria-controls="t4-2" aria-selected="false"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"/></svg><span>Security</span></button></li></ul><div class="tab-content tb-body flex-grow-1"><div class="tab-pane fade show active" id="t4-0" role="tabpanel" aria-labelledby="t4-0-tab" tabindex="0"><h3 class="h6 fw-semibold text-body-emphasis">General</h3><p class="small text-body-secondary mb-0">Workspace name, URL and default language. Changes apply to every member immediately.</p><input class="form-control mt-3" value="Atlas Studio" aria-label="Workspace name"></div><div class="tab-pane fade" id="t4-1" role="tabpanel" aria-labelledby="t4-1-tab" tabindex="0"><h3 class="h6 fw-semibold text-body-emphasis">Members</h3><p class="small text-body-secondary mb-2">8 people have access.</p><div class="d-flex"><img class="tb-face" src="https://i.pravatar.cc/64?img=5" alt="" width="32" height="32"><img class="tb-face" src="https://i.pravatar.cc/64?img=12" alt="" width="32" height="32"><img class="tb-face" src="https://i.pravatar.cc/64?img=32" alt="" width="32" height="32"></div><button type="button" class="btn btn-outline-primary rounded-pill btn-sm mt-3">Invite member</button></div><div class="tab-pane fade" id="t4-2" role="tabpanel" aria-labelledby="t4-2-tab" tabindex="0"><h3 class="h6 fw-semibold text-body-emphasis">Security</h3><p class="small text-body-secondary mb-0">Two-factor authentication is on. Last password change 41 days ago.</p><button type="button" class="btn btn-outline-primary rounded-pill btn-sm mt-3">Change password</button></div></div></div></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.

Free to use in personal and commercial projects under the MIT license.