Snippets Table

Bootstrap 5 Table with Fixed First Column

A wide employee table that scrolls horizontally while the name column stays pinned, with a live filter and status badges.

Bootstrap 5 No jQuery Jun 2019 3K views

<section class="wdw-stage"><div class="container" style="max-width:960px">
<div class="d-flex flex-column flex-sm-row justify-content-between align-items-sm-end gap-3 mb-4"><div><span class="wdw-eyebrow">Team</span><h2 class="wdw-heading h2 mb-1">Employee directory</h2><p class="wdw-muted mb-0">Scroll sideways on small screens: the name column stays pinned.</p></div>
<div><label for="tblFilter" class="visually-hidden">Filter employees</label><input id="tblFilter" type="search" class="form-control fx-filter" placeholder="Filter by name or role"></div></div>
<div class="wdw-card overflow-hidden" id="fxCard"><div class="table-responsive fx-wrap" tabindex="0" role="region" aria-label="Employee table, scrollable"><table class="table table-hover align-middle mb-0 fx-table"><thead><tr>
<th scope="col" class="fx-sticky text-uppercase small wdw-muted fw-bold">Employee</th>
<th scope="col" class="text-uppercase small wdw-muted fw-bold">Position</th>
<th scope="col" class="text-uppercase small wdw-muted fw-bold">Status</th>
<th scope="col" class="text-uppercase small wdw-muted fw-bold">Start date</th>
<th scope="col" class="text-uppercase small wdw-muted fw-bold">Address</th>
</tr></thead><tbody>
<tr><th scope="row" class="fx-sticky fw-normal"><div class="d-flex align-items-center gap-3"><span class="fx-avatar bg-primary-subtle text-primary-emphasis" aria-hidden="true">BG</span><div><div class="fw-semibold text-nowrap">Brandon Green</div><div class="small wdw-muted">[email protected]</div></div></div></th><td>CMO</td><td><span class="badge rounded-pill text-bg-success">Active</span></td><td class="text-nowrap">16 Nov 2012</td><td class="text-nowrap">New York, NY</td></tr>
<tr><th scope="row" class="fx-sticky fw-normal"><div class="d-flex align-items-center gap-3"><span class="fx-avatar bg-primary-subtle text-primary-emphasis" aria-hidden="true">KD</span><div><div class="fw-semibold text-nowrap">Kathy Daniels</div><div class="small wdw-muted">[email protected]</div></div></div></th><td>Marketing</td><td><span class="badge rounded-pill text-bg-success">Active</span></td><td class="text-nowrap">16 Nov 2015</td><td class="text-nowrap">Austin, TX</td></tr>
<tr><th scope="row" class="fx-sticky fw-normal"><div class="d-flex align-items-center gap-3"><span class="fx-avatar bg-primary-subtle text-primary-emphasis" aria-hidden="true">EA</span><div><div class="fw-semibold text-nowrap">Elizabeth Alvarado</div><div class="small wdw-muted">[email protected]</div></div></div></th><td>CFO</td><td><span class="badge rounded-pill text-bg-warning">Away</span></td><td class="text-nowrap">16 Nov 2013</td><td class="text-nowrap">Chicago, IL</td></tr>
<tr><th scope="row" class="fx-sticky fw-normal"><div class="d-flex align-items-center gap-3"><span class="fx-avatar bg-primary-subtle text-primary-emphasis" aria-hidden="true">MC</span><div><div class="fw-semibold text-nowrap">Michael Coleman</div><div class="small wdw-muted">[email protected]</div></div></div></th><td>Designer</td><td><span class="badge rounded-pill text-bg-success">Active</span></td><td class="text-nowrap">16 Nov 2013</td><td class="text-nowrap">Seattle, WA</td></tr>
<tr><th scope="row" class="fx-sticky fw-normal"><div class="d-flex align-items-center gap-3"><span class="fx-avatar bg-primary-subtle text-primary-emphasis" aria-hidden="true">JC</span><div><div class="fw-semibold text-nowrap">Jason Cox</div><div class="small wdw-muted">[email protected]</div></div></div></th><td>Developer</td><td><span class="badge rounded-pill text-bg-success">Active</span></td><td class="text-nowrap">16 Nov 2017</td><td class="text-nowrap">Denver, CO</td></tr>
<tr><th scope="row" class="fx-sticky fw-normal"><div class="d-flex align-items-center gap-3"><span class="fx-avatar bg-primary-subtle text-primary-emphasis" aria-hidden="true">CP</span><div><div class="fw-semibold text-nowrap">Christian Perkins</div><div class="small wdw-muted">[email protected]</div></div></div></th><td>Sales</td><td><span class="badge rounded-pill text-bg-secondary">Offline</span></td><td class="text-nowrap">16 Nov 2016</td><td class="text-nowrap">Boston, MA</td></tr>
<tr><th scope="row" class="fx-sticky fw-normal"><div class="d-flex align-items-center gap-3"><span class="fx-avatar bg-primary-subtle text-primary-emphasis" aria-hidden="true">EW</span><div><div class="fw-semibold text-nowrap">Emily Wheeler</div><div class="small wdw-muted">[email protected]</div></div></div></th><td>Support</td><td><span class="badge rounded-pill text-bg-warning">Away</span></td><td class="text-nowrap">16 Nov 2013</td><td class="text-nowrap">Portland, OR</td></tr>
<tr id="fxEmpty" hidden><td colspan="5" class="text-center wdw-muted py-5">No matching employees</td></tr>
</tbody></table></div></div>
<p class="visually-hidden" role="status" aria-live="polite" id="fxCount"></p></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.