Snippets Buttons

Bootstrap 5 Order Table with Toggle Switches

An orders table with a switch on every row, a select-all switch, colour-coded status badges and a bulk action that enables once rows are selected.

Bootstrap 5 No jQuery Jun 2020 3.6K views

<section class="wdw-stage">
  <div class="container w-100" style="max-width:960px">
    <div class="wdw-card overflow-hidden" id="orders">
      <div class="d-flex flex-wrap align-items-center justify-content-between gap-3 p-4">
        <div>
          <h2 class="h4 wdw-heading mb-1">Orders</h2>
          <p class="wdw-muted small mb-0" id="otSummary" aria-live="polite">No orders selected</p>
        </div>
        <button type="button" class="btn btn-primary rounded-pill px-4" id="otBulk" disabled>Export selected</button>
      </div>
      <table class="table table-hover align-middle mb-0">
        <thead>
          <tr>
            <th scope="col" class="ps-3 ps-md-4 bg-body-tertiary"><div class="form-check form-switch m-0"><input class="form-check-input" type="checkbox" role="switch" id="otAll" aria-label="Select all orders"></div></th>
            <th scope="col" class="bg-body-tertiary">Order</th><th scope="col" class="bg-body-tertiary d-none d-md-table-cell">Customer</th><th scope="col" class="bg-body-tertiary d-none d-md-table-cell">Status</th><th scope="col" class="text-end bg-body-tertiary">Total</th><th scope="col" class="bg-body-tertiary d-none d-md-table-cell">Created</th><th scope="col" class="bg-body-tertiary"><span class="visually-hidden">Actions</span></th>
          </tr>
        </thead>
        <tbody>
            <tr>
              <td class="ps-3 ps-md-4"><div class="form-check form-switch m-0"><input class="form-check-input ot-row" type="checkbox" role="switch" id="ot0" aria-label="Select order SO-13487" checked></div></td>
              <td><span class="fw-semibold">#SO-13487</span><div class="d-md-none small mt-1 text-body-secondary">Gasper Antunes</div><div class="d-md-none mt-1"><span class="badge rounded-pill bg-success-subtle text-success-emphasis border border-success-subtle">Fulfilled</span></div></td>
              <td class="d-none d-md-table-cell"><div class="d-flex align-items-center gap-2"><span class="ot-av rounded-circle bg-primary-subtle text-primary-emphasis fw-bold" aria-hidden="true">GA</span>Gasper Antunes</div></td>
              <td class="d-none d-md-table-cell"><span class="badge rounded-pill bg-success-subtle text-success-emphasis border border-success-subtle">Fulfilled</span></td>
              <td class="text-end fw-semibold ot-num">$2,674.00</td>
              <td class="text-body-secondary d-none d-md-table-cell">Today</td>
              <td class="pe-3 pe-md-4 text-end">
                <div class="dropdown">
                  <button type="button" class="btn btn-sm btn-light rounded-circle p-0 ot-more" style="width:44px;min-height:44px" data-bs-toggle="dropdown" aria-expanded="false" aria-label="Actions for SO-13487"><svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><circle cx="5" cy="12" r="1.8"/><circle cx="12" cy="12" r="1.8"/><circle cx="19" cy="12" r="1.8"/></svg></button>
                  <ul class="dropdown-menu dropdown-menu-end shadow-sm"><li><button type="button" class="dropdown-item">View</button></li><li><button type="button" class="dropdown-item">Duplicate</button></li><li><hr class="dropdown-divider"></li><li><button type="button" class="dropdown-item text-danger">Cancel order</button></li></ul>
                </div>
              </td>
            </tr>
            <tr>
              <td class="ps-3 ps-md-4"><div class="form-check form-switch m-0"><input class="form-check-input ot-row" type="checkbox" role="switch" id="ot1" aria-label="Select order SO-13453"></div></td>
              <td><span class="fw-semibold">#SO-13453</span><div class="d-md-none small mt-1 text-body-secondary">Aartsen van</div><div class="d-md-none mt-1"><span class="badge rounded-pill bg-primary-subtle text-primary-emphasis border border-primary-subtle">Confirmed</span></div></td>
              <td class="d-none d-md-table-cell"><div class="d-flex align-items-center gap-2"><span class="ot-av rounded-circle bg-primary-subtle text-primary-emphasis fw-bold" aria-hidden="true">AV</span>Aartsen van</div></td>
              <td class="d-none d-md-table-cell"><span class="badge rounded-pill bg-primary-subtle text-primary-emphasis border border-primary-subtle">Confirmed</span></td>
              <td class="text-end fw-semibold ot-num">$3,454.00</td>
              <td class="text-body-secondary d-none d-md-table-cell">Yesterday</td>
              <td class="pe-3 pe-md-4 text-end">
                <div class="dropdown">
                  <button type="button" class="btn btn-sm btn-light rounded-circle p-0 ot-more" style="width:44px;min-height:44px" data-bs-toggle="dropdown" aria-expanded="false" aria-label="Actions for SO-13453"><svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><circle cx="5" cy="12" r="1.8"/><circle cx="12" cy="12" r="1.8"/><circle cx="19" cy="12" r="1.8"/></svg></button>
                  <ul class="dropdown-menu dropdown-menu-end shadow-sm"><li><button type="button" class="dropdown-item">View</button></li><li><button type="button" class="dropdown-item">Duplicate</button></li><li><hr class="dropdown-divider"></li><li><button type="button" class="dropdown-item text-danger">Cancel order</button></li></ul>
                </div>
              </td>
            </tr>
            <tr>
              <td class="ps-3 ps-md-4"><div class="form-check form-switch m-0"><input class="form-check-input ot-row" type="checkbox" role="switch" id="ot2" aria-label="Select order SO-13498" checked></div></td>
              <td><span class="fw-semibold">#SO-13498</span><div class="d-md-none small mt-1 text-body-secondary">Trashes Habard</div><div class="d-md-none mt-1"><span class="badge rounded-pill bg-warning-subtle text-warning-emphasis border border-warning-subtle">Partially shipped</span></div></td>
              <td class="d-none d-md-table-cell"><div class="d-flex align-items-center gap-2"><span class="ot-av rounded-circle bg-primary-subtle text-primary-emphasis fw-bold" aria-hidden="true">TH</span>Trashes Habard</div></td>
              <td class="d-none d-md-table-cell"><span class="badge rounded-pill bg-warning-subtle text-warning-emphasis border border-warning-subtle">Partially shipped</span></td>
              <td class="text-end fw-semibold ot-num">$6,274.00</td>
              <td class="text-body-secondary d-none d-md-table-cell">May 12, 2026</td>
              <td class="pe-3 pe-md-4 text-end">
                <div class="dropdown">
                  <button type="button" class="btn btn-sm btn-light rounded-circle p-0 ot-more" style="width:44px;min-height:44px" data-bs-toggle="dropdown" aria-expanded="false" aria-label="Actions for SO-13498"><svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><circle cx="5" cy="12" r="1.8"/><circle cx="12" cy="12" r="1.8"/><circle cx="19" cy="12" r="1.8"/></svg></button>
                  <ul class="dropdown-menu dropdown-menu-end shadow-sm"><li><button type="button" class="dropdown-item">View</button></li><li><button type="button" class="dropdown-item">Duplicate</button></li><li><hr class="dropdown-divider"></li><li><button type="button" class="dropdown-item text-danger">Cancel order</button></li></ul>
                </div>
              </td>
            </tr>
            <tr>
              <td class="ps-3 ps-md-4"><div class="form-check form-switch m-0"><input class="form-check-input ot-row" type="checkbox" role="switch" id="ot3" aria-label="Select order SO-16499"></div></td>
              <td><span class="fw-semibold">#SO-16499</span><div class="d-md-none small mt-1 text-body-secondary">Samban Hubart</div><div class="d-md-none mt-1"><span class="badge rounded-pill bg-success-subtle text-success-emphasis border border-success-subtle">Fulfilled</span></div></td>
              <td class="d-none d-md-table-cell"><div class="d-flex align-items-center gap-2"><span class="ot-av rounded-circle bg-primary-subtle text-primary-emphasis fw-bold" aria-hidden="true">SH</span>Samban Hubart</div></td>
              <td class="d-none d-md-table-cell"><span class="badge rounded-pill bg-success-subtle text-success-emphasis border border-success-subtle">Fulfilled</span></td>
              <td class="text-end fw-semibold ot-num">$6,375.00</td>
              <td class="text-body-secondary d-none d-md-table-cell">May 11, 2026</td>
              <td class="pe-3 pe-md-4 text-end">
                <div class="dropdown">
                  <button type="button" class="btn btn-sm btn-light rounded-circle p-0 ot-more" style="width:44px;min-height:44px" data-bs-toggle="dropdown" aria-expanded="false" aria-label="Actions for SO-16499"><svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><circle cx="5" cy="12" r="1.8"/><circle cx="12" cy="12" r="1.8"/><circle cx="19" cy="12" r="1.8"/></svg></button>
                  <ul class="dropdown-menu dropdown-menu-end shadow-sm"><li><button type="button" class="dropdown-item">View</button></li><li><button type="button" class="dropdown-item">Duplicate</button></li><li><hr class="dropdown-divider"></li><li><button type="button" class="dropdown-item text-danger">Cancel order</button></li></ul>
                </div>
              </td>
            </tr>
            <tr>
              <td class="ps-3 ps-md-4"><div class="form-check form-switch m-0"><input class="form-check-input ot-row" type="checkbox" role="switch" id="ot4" aria-label="Select order SO-16512"></div></td>
              <td><span class="fw-semibold">#SO-16512</span><div class="d-md-none small mt-1 text-body-secondary">Linnea Moberg</div><div class="d-md-none mt-1"><span class="badge rounded-pill bg-danger-subtle text-danger-emphasis border border-danger-subtle">Cancelled</span></div></td>
              <td class="d-none d-md-table-cell"><div class="d-flex align-items-center gap-2"><span class="ot-av rounded-circle bg-primary-subtle text-primary-emphasis fw-bold" aria-hidden="true">LM</span>Linnea Moberg</div></td>
              <td class="d-none d-md-table-cell"><span class="badge rounded-pill bg-danger-subtle text-danger-emphasis border border-danger-subtle">Cancelled</span></td>
              <td class="text-end fw-semibold ot-num">$1,120.00</td>
              <td class="text-body-secondary d-none d-md-table-cell">May 9, 2026</td>
              <td class="pe-3 pe-md-4 text-end">
                <div class="dropdown">
                  <button type="button" class="btn btn-sm btn-light rounded-circle p-0 ot-more" style="width:44px;min-height:44px" data-bs-toggle="dropdown" aria-expanded="false" aria-label="Actions for SO-16512"><svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><circle cx="5" cy="12" r="1.8"/><circle cx="12" cy="12" r="1.8"/><circle cx="19" cy="12" r="1.8"/></svg></button>
                  <ul class="dropdown-menu dropdown-menu-end shadow-sm"><li><button type="button" class="dropdown-item">View</button></li><li><button type="button" class="dropdown-item">Duplicate</button></li><li><hr class="dropdown-divider"></li><li><button type="button" class="dropdown-item text-danger">Cancel order</button></li></ul>
                </div>
              </td>
            </tr>
        </tbody>
      </table>
    </div>
  </div>
</section>

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