Snippets Table

Bootstrap 5 Table with Add, Edit and Delete Row Actions

An editable team table with add, inline edit and delete actions, plus role badges and an empty state. Edits are validated before they are saved.

Bootstrap 5 No jQuery Nov 2019 22K views

<section class="wdw-stage tbl-stage">
  <div class="container" style="max-width: 920px;">
    <div class="card wdw-card-sm">
      <div class="card-body p-3 p-md-4">
        <div class="d-flex flex-wrap align-items-center justify-content-between gap-3 mb-4">
          <div>
            <h1 class="h4 wdw-heading mb-1">Team members</h1>
            <p class="text-body-secondary small mb-0"><span id="tblCount">3</span> people with access</p>
          </div>
          <button type="button" class="btn btn-primary rounded-pill px-4" id="tblAdd">
            <svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor" class="me-2" aria-hidden="true"><path d="M8 2a.75.75 0 0 1 .75.75v4.5h4.5a.75.75 0 0 1 0 1.5h-4.5v4.5a.75.75 0 0 1-1.5 0v-4.5h-4.5a.75.75 0 0 1 0-1.5h4.5v-4.5A.75.75 0 0 1 8 2z"/></svg>Add member
          </button>
        </div>
        <table class="table align-middle mb-0 tbl">
          <thead>
            <tr class="text-uppercase">
              <th scope="col">Member</th><th scope="col">Role</th><th scope="col">Status</th><th scope="col" class="text-end">Actions</th>
            </tr>
          </thead>
          <tbody id="tblBody"></tbody>
        </table>
        <div id="tblEmpty" class="text-center py-5 d-none">
          <span class="tbl-empty-icon d-inline-flex align-items-center justify-content-center rounded-circle mb-3" aria-hidden="true"><svg width="28" height="28" viewBox="0 0 16 16" fill="currentColor"><path d="M7 14s-1 0-1-1 1-4 5-4 5 3 5 4-1 1-1 1zm4-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6m-5.784 6A2.24 2.24 0 0 1 5 13c0-1.355.68-2.75 1.936-3.72A6.3 6.3 0 0 0 5 9c-4 0-5 3-5 4s1 1 1 1zM4.5 8a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5"/></svg></span>
          <h2 class="h6 fw-semibold text-body-emphasis">No members yet</h2>
          <p class="text-body-secondary small mb-3">Invite your first teammate to get started.</p>
          <button type="button" class="btn btn-primary rounded-pill px-4" data-action="add-empty">Add member</button>
        </div>
      </div>
    </div>
  </div>
  <div id="tblLive" class="visually-hidden" role="status" aria-live="polite"></div>
  <div class="toast-container position-fixed bottom-0 start-50 translate-middle-x p-3">
    <div id="tblToast" class="toast align-items-center text-bg-dark border-0" role="status" aria-live="polite" aria-atomic="true" data-bs-delay="6000">
      <div class="d-flex align-items-center">
        <div class="toast-body" id="tblToastMsg">Member removed.</div>
        <button type="button" class="btn btn-sm btn-link text-white fw-semibold me-1" id="tblUndo">Undo</button>
        <button type="button" class="btn-close btn-close-white me-2" data-bs-dismiss="toast" aria-label="Dismiss"></button>
      </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.