Snippets Data

Bootstrap 5 User Management Data Table

A user management table with avatars, role and status badges, row removal, CSV export and pagination.

Bootstrap 5 No jQuery Sep 2020 4.6K views

<section class="wdw-stage">
  <div class="container" style="max-width: 980px">
    <div class="wdw-card overflow-hidden">
      <div class="p-4 d-flex flex-wrap align-items-center justify-content-between gap-3">
        <div>
          <span class="wdw-eyebrow">Team</span>
          <h1 class="wdw-heading h3 mb-0">User management</h1>
        </div>
        <div class="d-flex flex-wrap gap-2">
          <button type="button" class="btn btn-outline-secondary um-outline rounded-pill" id="umExport">
            <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="M12 3v12m0 0l-4-4m4 4l4-4M4 21h16"/></svg>Export CSV</button>
          <button type="button" class="btn btn-primary rounded-pill" data-bs-toggle="tooltip" data-bs-title="Invite a teammate">
            <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="M12 5v14M5 12h14"/></svg>Add user</button>
        </div>
      </div>
      <div class="table-responsive">
        <table class="table align-middle mb-0 um-table" id="umTable">
          <thead><tr><th scope="col" class="ps-4">User</th><th scope="col" class="d-none d-md-table-cell">Created</th><th scope="col" class="d-none d-sm-table-cell">Role</th><th scope="col">Status</th><th scope="col" class="text-end pe-4"><span class="visually-hidden">Actions</span></th></tr></thead>
          <tbody>
            <tr>
              <td class="ps-4"><div class="d-flex align-items-center gap-3"><img src="https://i.pravatar.cc/80?img=12" width="40" height="40" class="rounded-circle d-none d-sm-block" alt=""><div><div class="fw-semibold text-body-emphasis">Michael Holz</div><div class="small wdw-muted">[email protected]</div></div></div></td>
              <td class="text-nowrap wdw-muted d-none d-md-table-cell">04 Oct 2013</td>
              <td class="d-none d-sm-table-cell"><span class="badge rounded-pill bg-primary-subtle text-primary-emphasis um-role">Admin</span></td>
              <td><span class="badge rounded-pill bg-success-subtle text-success-emphasis"><span class="status-dot bg-success"></span>Active</span></td>
              <td class="text-end text-nowrap pe-4"><button type="button" class="btn btn-sm btn-outline-secondary border-0 px-2 user-edit" data-bs-toggle="modal" data-bs-target="#umEditModal" aria-label="Edit Michael Holz"><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="M12 20h9"/><path d="M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z"/></svg></button><button type="button" class="btn btn-sm btn-outline-danger border-0 px-2 user-remove" aria-label="Remove Michael Holz"><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="M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"/></svg></button></td>
            </tr>
            <tr>
              <td class="ps-4"><div class="d-flex align-items-center gap-3"><img src="https://i.pravatar.cc/80?img=47" width="40" height="40" class="rounded-circle d-none d-sm-block" alt=""><div><div class="fw-semibold text-body-emphasis">Paula Wilson</div><div class="small wdw-muted">[email protected]</div></div></div></td>
              <td class="text-nowrap wdw-muted d-none d-md-table-cell">05 Aug 2014</td>
              <td class="d-none d-sm-table-cell"><span class="badge rounded-pill bg-body-secondary text-body-emphasis um-role">Publisher</span></td>
              <td><span class="badge rounded-pill bg-success-subtle text-success-emphasis"><span class="status-dot bg-success"></span>Active</span></td>
              <td class="text-end text-nowrap pe-4"><button type="button" class="btn btn-sm btn-outline-secondary border-0 px-2 user-edit" data-bs-toggle="modal" data-bs-target="#umEditModal" aria-label="Edit Paula Wilson"><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="M12 20h9"/><path d="M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z"/></svg></button><button type="button" class="btn btn-sm btn-outline-danger border-0 px-2 user-remove" aria-label="Remove Paula Wilson"><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="M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"/></svg></button></td>
            </tr>
            <tr>
              <td class="ps-4"><div class="d-flex align-items-center gap-3"><img src="https://i.pravatar.cc/80?img=33" width="40" height="40" class="rounded-circle d-none d-sm-block" alt=""><div><div class="fw-semibold text-body-emphasis">Antonio Moreno</div><div class="small wdw-muted">[email protected]</div></div></div></td>
              <td class="text-nowrap wdw-muted d-none d-md-table-cell">11 May 2015</td>
              <td class="d-none d-sm-table-cell"><span class="badge rounded-pill bg-body-secondary text-body-emphasis um-role">Publisher</span></td>
              <td><span class="badge rounded-pill bg-danger-subtle text-danger-emphasis"><span class="status-dot bg-danger"></span>Suspended</span></td>
              <td class="text-end text-nowrap pe-4"><button type="button" class="btn btn-sm btn-outline-secondary border-0 px-2 user-edit" data-bs-toggle="modal" data-bs-target="#umEditModal" aria-label="Edit Antonio Moreno"><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="M12 20h9"/><path d="M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z"/></svg></button><button type="button" class="btn btn-sm btn-outline-danger border-0 px-2 user-remove" aria-label="Remove Antonio Moreno"><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="M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"/></svg></button></td>
            </tr>
            <tr>
              <td class="ps-4"><div class="d-flex align-items-center gap-3"><img src="https://i.pravatar.cc/80?img=5" width="40" height="40" class="rounded-circle d-none d-sm-block" alt=""><div><div class="fw-semibold text-body-emphasis">Mary Saveley</div><div class="small wdw-muted">[email protected]</div></div></div></td>
              <td class="text-nowrap wdw-muted d-none d-md-table-cell">06 Sep 2016</td>
              <td class="d-none d-sm-table-cell"><span class="badge rounded-pill bg-body-secondary text-body-emphasis um-role">Reviewer</span></td>
              <td><span class="badge rounded-pill bg-success-subtle text-success-emphasis"><span class="status-dot bg-success"></span>Active</span></td>
              <td class="text-end text-nowrap pe-4"><button type="button" class="btn btn-sm btn-outline-secondary border-0 px-2 user-edit" data-bs-toggle="modal" data-bs-target="#umEditModal" aria-label="Edit Mary Saveley"><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="M12 20h9"/><path d="M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z"/></svg></button><button type="button" class="btn btn-sm btn-outline-danger border-0 px-2 user-remove" aria-label="Remove Mary Saveley"><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="M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"/></svg></button></td>
            </tr>
            <tr>
              <td class="ps-4"><div class="d-flex align-items-center gap-3"><img src="https://i.pravatar.cc/80?img=68" width="40" height="40" class="rounded-circle d-none d-sm-block" alt=""><div><div class="fw-semibold text-body-emphasis">Martin Sommer</div><div class="small wdw-muted">[email protected]</div></div></div></td>
              <td class="text-nowrap wdw-muted d-none d-md-table-cell">12 Aug 2017</td>
              <td class="d-none d-sm-table-cell"><span class="badge rounded-pill bg-body-secondary text-body-emphasis um-role">Moderator</span></td>
              <td><span class="badge rounded-pill bg-warning-subtle text-warning-emphasis"><span class="status-dot bg-warning"></span>Inactive</span></td>
              <td class="text-end text-nowrap pe-4"><button type="button" class="btn btn-sm btn-outline-secondary border-0 px-2 user-edit" data-bs-toggle="modal" data-bs-target="#umEditModal" aria-label="Edit Martin Sommer"><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="M12 20h9"/><path d="M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z"/></svg></button><button type="button" class="btn btn-sm btn-outline-danger border-0 px-2 user-remove" aria-label="Remove Martin Sommer"><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="M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"/></svg></button></td>
            </tr>
          </tbody>
        </table>
      </div>
      <div class="p-4 d-flex flex-wrap align-items-center justify-content-between gap-3 border-top">
        <span class="small wdw-muted" id="umCount">Showing 1–5 of 25 users</span>
        <nav aria-label="Users pages"><ul class="pagination pagination-sm mb-0 gap-1" id="umPager"></ul></nav>
      </div>
    </div>
  </div>
</section>
<div class="modal fade" id="umEditModal" tabindex="-1" aria-labelledby="umEditTitle" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered">
    <form class="modal-content border-0 shadow" id="umEditForm">
      <div class="modal-header border-0 pb-0">
        <h2 class="modal-title h5 wdw-heading" id="umEditTitle">Edit user</h2>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body d-grid gap-3">
        <div><label class="form-label small fw-semibold" for="umEditName">Name</label><input class="form-control" id="umEditName" required></div>
        <div><label class="form-label small fw-semibold" for="umEditRole">Role</label>
          <select class="form-select" id="umEditRole"><option>Admin</option><option>Publisher</option><option>Reviewer</option><option>Moderator</option></select></div>
      </div>
      <div class="modal-footer border-0 pt-0">
        <button type="button" class="btn btn-outline-secondary um-outline rounded-pill" data-bs-dismiss="modal">Cancel</button>
        <button type="submit" class="btn btn-primary rounded-pill">Save changes</button>
      </div>
    </form>
  </div>
</div>
<div class="toast-container position-fixed bottom-0 start-50 translate-middle-x p-3">
  <div class="toast align-items-center text-bg-dark border-0" id="umToast" role="status" aria-live="polite" aria-atomic="true">
    <div class="d-flex align-items-center">
      <div class="toast-body" id="umToastMsg">User removed</div>
      <button type="button" class="btn btn-sm btn-link link-light fw-semibold me-2" id="umUndo">Undo</button>
      <button type="button" class="btn-close btn-close-white me-2" data-bs-dismiss="toast" aria-label="Close"></button>
    </div>
  </div>
</div>

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