Snippets Dropdown

Bootstrap 5 Data Table with Search, Sorting and Pagination

A data table card with live search, sortable columns, a page-size selector and numbered pagination, all in vanilla JavaScript.

Bootstrap 5 Bootstrap 6 No jQuery Jul 2019 8.3K views

<section class="wdw-stage">
  <div class="container" style="max-width:860px">
    <div class="wdw-card dt overflow-hidden">
      <div class="d-flex flex-wrap align-items-end justify-content-between gap-3 p-4">
        <div><span class="wdw-eyebrow">Team</span><h1 class="h4 wdw-heading mb-0 d-flex align-items-center gap-2">Members <span class="badge rounded-pill text-primary-emphasis bg-primary-subtle" id="dtCount">12</span></h1></div>
        <div class="d-flex align-items-center gap-2">
          <label class="small wdw-muted" for="dtSize">Show</label>
          <select id="dtSize" aria-controls="dtTable" class="form-select form-select-sm w-auto"><option>5</option><option>10</option></select>
          <label class="visually-hidden" for="dtSearch">Search members</label>
          <input type="search" id="dtSearch" aria-controls="dtTable" class="form-control rounded-pill" style="width:200px" placeholder="Search">
        </div>
      </div>
      <div class="table-responsive">
        <table class="table table-hover align-middle mb-0" id="dtTable">
          <thead><tr>
            <th scope="col" aria-sort="none"><button type="button" class="dt-sort" data-col="0">Member <span aria-hidden="true"></span></button></th>
            <th scope="col" aria-sort="none"><button type="button" class="dt-sort" data-col="1">Role <span aria-hidden="true"></span></button></th>
            <th scope="col" aria-sort="none" class="d-none d-sm-table-cell"><button type="button" class="dt-sort" data-col="2">Status <span aria-hidden="true"></span></button></th>
            <th scope="col" aria-sort="none" class="d-none d-md-table-cell"><button type="button" class="dt-sort" data-col="3">Last active <span aria-hidden="true"></span></button></th>
          </tr></thead>
          <tbody>
<tr><td data-sort="Daniel Danny"><div class="d-flex align-items-center gap-3"><span class="wdw-icon dt-av" aria-hidden="true">DD</span><div class="min-w-0"><div class="fw-semibold">Daniel Danny</div><div class="small text-body-secondary dt-mail">[email protected]</div></div></div></td><td><span class="badge rounded-pill dt-role dt-admin">Admin</span></td><td class="d-none d-sm-table-cell"><span class="d-inline-flex align-items-center gap-2"><span class="dt-dot bg-success" aria-hidden="true"></span>Active</span></td><td class="d-none d-md-table-cell text-body-secondary">2 min ago</td></tr>
<tr><td data-sort="Samuel Ortiz"><div class="d-flex align-items-center gap-3"><span class="wdw-icon dt-av" aria-hidden="true">SO</span><div class="min-w-0"><div class="fw-semibold">Samuel Ortiz</div><div class="small text-body-secondary dt-mail">[email protected]</div></div></div></td><td><span class="badge rounded-pill dt-role dt-editor">Editor</span></td><td class="d-none d-sm-table-cell"><span class="d-inline-flex align-items-center gap-2"><span class="dt-dot bg-success" aria-hidden="true"></span>Active</span></td><td class="d-none d-md-table-cell text-body-secondary">1 hour ago</td></tr>
<tr><td data-sort="Priya Nair"><div class="d-flex align-items-center gap-3"><span class="wdw-icon dt-av" aria-hidden="true">PN</span><div class="min-w-0"><div class="fw-semibold">Priya Nair</div><div class="small text-body-secondary dt-mail">[email protected]</div></div></div></td><td><span class="badge rounded-pill dt-role dt-viewer">Viewer</span></td><td class="d-none d-sm-table-cell"><span class="d-inline-flex align-items-center gap-2"><span class="dt-dot bg-warning" aria-hidden="true"></span>Invited</span></td><td class="d-none d-md-table-cell text-body-secondary">Pending</td></tr>
<tr><td data-sort="Maya Chen"><div class="d-flex align-items-center gap-3"><span class="wdw-icon dt-av" aria-hidden="true">MC</span><div class="min-w-0"><div class="fw-semibold">Maya Chen</div><div class="small text-body-secondary dt-mail">[email protected]</div></div></div></td><td><span class="badge rounded-pill dt-role dt-editor">Editor</span></td><td class="d-none d-sm-table-cell"><span class="d-inline-flex align-items-center gap-2"><span class="dt-dot bg-success" aria-hidden="true"></span>Active</span></td><td class="d-none d-md-table-cell text-body-secondary">Yesterday</td></tr>
<tr><td data-sort="Tom Becker"><div class="d-flex align-items-center gap-3"><span class="wdw-icon dt-av" aria-hidden="true">TB</span><div class="min-w-0"><div class="fw-semibold">Tom Becker</div><div class="small text-body-secondary dt-mail">[email protected]</div></div></div></td><td><span class="badge rounded-pill dt-role dt-viewer">Viewer</span></td><td class="d-none d-sm-table-cell"><span class="d-inline-flex align-items-center gap-2"><span class="dt-dot bg-success" aria-hidden="true"></span>Active</span></td><td class="d-none d-md-table-cell text-body-secondary">3 days ago</td></tr>
<tr><td data-sort="Lena Fischer"><div class="d-flex align-items-center gap-3"><span class="wdw-icon dt-av" aria-hidden="true">LF</span><div class="min-w-0"><div class="fw-semibold">Lena Fischer</div><div class="small text-body-secondary dt-mail">[email protected]</div></div></div></td><td><span class="badge rounded-pill dt-role dt-admin">Admin</span></td><td class="d-none d-sm-table-cell"><span class="d-inline-flex align-items-center gap-2"><span class="dt-dot bg-success" aria-hidden="true"></span>Active</span></td><td class="d-none d-md-table-cell text-body-secondary">Today</td></tr>
<tr><td data-sort="Omar Haddad"><div class="d-flex align-items-center gap-3"><span class="wdw-icon dt-av" aria-hidden="true">OH</span><div class="min-w-0"><div class="fw-semibold">Omar Haddad</div><div class="small text-body-secondary dt-mail">[email protected]</div></div></div></td><td><span class="badge rounded-pill dt-role dt-editor">Editor</span></td><td class="d-none d-sm-table-cell"><span class="d-inline-flex align-items-center gap-2"><span class="dt-dot bg-warning" aria-hidden="true"></span>Invited</span></td><td class="d-none d-md-table-cell text-body-secondary">Pending</td></tr>
<tr><td data-sort="Sofia Rossi"><div class="d-flex align-items-center gap-3"><span class="wdw-icon dt-av" aria-hidden="true">SR</span><div class="min-w-0"><div class="fw-semibold">Sofia Rossi</div><div class="small text-body-secondary dt-mail">[email protected]</div></div></div></td><td><span class="badge rounded-pill dt-role dt-viewer">Viewer</span></td><td class="d-none d-sm-table-cell"><span class="d-inline-flex align-items-center gap-2"><span class="dt-dot bg-success" aria-hidden="true"></span>Active</span></td><td class="d-none d-md-table-cell text-body-secondary">Last week</td></tr>
<tr><td data-sort="Ethan Brooks"><div class="d-flex align-items-center gap-3"><span class="wdw-icon dt-av" aria-hidden="true">EB</span><div class="min-w-0"><div class="fw-semibold">Ethan Brooks</div><div class="small text-body-secondary dt-mail">[email protected]</div></div></div></td><td><span class="badge rounded-pill dt-role dt-viewer">Viewer</span></td><td class="d-none d-sm-table-cell"><span class="d-inline-flex align-items-center gap-2"><span class="dt-dot bg-success" aria-hidden="true"></span>Active</span></td><td class="d-none d-md-table-cell text-body-secondary">Yesterday</td></tr>
<tr><td data-sort="Hana Sato"><div class="d-flex align-items-center gap-3"><span class="wdw-icon dt-av" aria-hidden="true">HS</span><div class="min-w-0"><div class="fw-semibold">Hana Sato</div><div class="small text-body-secondary dt-mail">[email protected]</div></div></div></td><td><span class="badge rounded-pill dt-role dt-editor">Editor</span></td><td class="d-none d-sm-table-cell"><span class="d-inline-flex align-items-center gap-2"><span class="dt-dot bg-success" aria-hidden="true"></span>Active</span></td><td class="d-none d-md-table-cell text-body-secondary">2 days ago</td></tr>
<tr><td data-sort="Lucas Silva"><div class="d-flex align-items-center gap-3"><span class="wdw-icon dt-av" aria-hidden="true">LS</span><div class="min-w-0"><div class="fw-semibold">Lucas Silva</div><div class="small text-body-secondary dt-mail">[email protected]</div></div></div></td><td><span class="badge rounded-pill dt-role dt-viewer">Viewer</span></td><td class="d-none d-sm-table-cell"><span class="d-inline-flex align-items-center gap-2"><span class="dt-dot bg-warning" aria-hidden="true"></span>Invited</span></td><td class="d-none d-md-table-cell text-body-secondary">Pending</td></tr>
<tr><td data-sort="Amara Okafor"><div class="d-flex align-items-center gap-3"><span class="wdw-icon dt-av" aria-hidden="true">AO</span><div class="min-w-0"><div class="fw-semibold">Amara Okafor</div><div class="small text-body-secondary dt-mail">[email protected]</div></div></div></td><td><span class="badge rounded-pill dt-role dt-admin">Admin</span></td><td class="d-none d-sm-table-cell"><span class="d-inline-flex align-items-center gap-2"><span class="dt-dot bg-success" aria-hidden="true"></span>Active</span></td><td class="d-none d-md-table-cell text-body-secondary">Today</td></tr>
<tr id="dtEmpty" hidden><td colspan="4" class="text-center text-body-secondary py-5">No members match your search.</td></tr>
          </tbody>
        </table>
      </div>
      <div class="d-flex flex-wrap align-items-center justify-content-between gap-3 p-4">
        <small class="wdw-muted" id="dtInfo" aria-live="polite"></small>
        <nav aria-label="Table pages"><ul class="pagination mb-0" id="dtPager"></ul></nav>
      </div>
    </div>
  </div>
</section>

Built on Bootstrap 6.0.0-alpha.1 (ES modules, no jQuery). Load Bootstrap through an import map and run the JavaScript as type="module" — the downloaded file is already set up that way. Alpha releases can still change class names.

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