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.
<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>
/* Web Designer Wall library style — shared base for every Bootstrap 5 snippet.
Indigo accent, Plus Jakarta Sans, soft cards, pill buttons. Works in light and dark. */
@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap");
:root,
[data-bs-theme="light"] {
--wdw-font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
--bs-body-font-family: var(--wdw-font);
--bs-primary: #4f46e5;
--bs-primary-rgb: 79, 70, 229;
--bs-primary-text-emphasis: #3730a3;
--bs-primary-bg-subtle: #eef2ff;
--bs-primary-border-subtle: #c7d2fe;
--bs-link-color: #4f46e5;
--bs-link-color-rgb: 79, 70, 229;
--bs-link-hover-color: #4338ca;
--bs-link-hover-color-rgb: 67, 56, 202;
--bs-focus-ring-color: rgba(79, 70, 229, 0.25);
--bs-border-radius: 0.75rem;
--bs-border-radius-lg: 1rem;
--bs-border-radius-xl: 1.25rem;
--wdw-radius-card: 1.25rem;
--wdw-shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 16px 40px -16px rgba(16, 24, 40, 0.22);
--wdw-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 12px -4px rgba(16, 24, 40, 0.12);
--wdw-stage: #f5f6fb;
}
[data-bs-theme="dark"] {
--bs-primary: #818cf8;
--bs-primary-rgb: 129, 140, 248;
--bs-primary-text-emphasis: #c7d2fe;
--bs-primary-bg-subtle: rgba(129, 140, 248, 0.14);
--bs-primary-border-subtle: rgba(129, 140, 248, 0.35);
--bs-link-color: #a5b4fc;
--bs-link-color-rgb: 165, 180, 252;
--bs-link-hover-color: #c7d2fe;
--bs-link-hover-color-rgb: 199, 210, 254;
--bs-focus-ring-color: rgba(129, 140, 248, 0.35);
--wdw-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px -16px rgba(0, 0, 0, 0.7);
--wdw-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px -4px rgba(0, 0, 0, 0.5);
--wdw-stage: #0f1117;
}
body { font-family: var(--wdw-font); -webkit-font-smoothing: antialiased; }
/* Bootstrap compiles its blue into these components; point them at the accent. */
.btn-primary {
--bs-btn-bg: var(--bs-primary); --bs-btn-border-color: var(--bs-primary);
--bs-btn-hover-bg: #4338ca; --bs-btn-hover-border-color: #4338ca;
--bs-btn-active-bg: #3730a3; --bs-btn-active-border-color: #3730a3;
--bs-btn-disabled-bg: var(--bs-primary); --bs-btn-disabled-border-color: var(--bs-primary);
--bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}
[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #0f1117; --bs-btn-hover-bg: #a5b4fc; --bs-btn-hover-border-color: #a5b4fc; --bs-btn-hover-color: #0f1117; --bs-btn-active-color: #0f1117; }
.btn-outline-primary {
--bs-btn-color: var(--bs-primary); --bs-btn-border-color: var(--bs-primary);
--bs-btn-hover-bg: var(--bs-primary); --bs-btn-hover-border-color: var(--bs-primary);
--bs-btn-active-bg: var(--bs-primary); --bs-btn-active-border-color: var(--bs-primary);
--bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}
.btn { --bs-btn-font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; }
.btn-sm { min-height: 36px; }
.form-control, .form-select { min-height: 44px; border-radius: .75rem; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: rgba(var(--bs-primary-rgb), .6); box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.form-check-input:checked { background-color: var(--bs-primary); border-color: var(--bs-primary); }
.nav-pills { --bs-nav-pills-link-active-bg: var(--bs-primary); }
.nav { --bs-nav-link-color: var(--bs-secondary-color); --bs-nav-link-hover-color: var(--bs-emphasis-color); }
.pagination { --bs-pagination-active-bg: var(--bs-primary); --bs-pagination-active-border-color: var(--bs-primary); --bs-pagination-color: var(--bs-body-color); --bs-pagination-focus-box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.progress, .progress-stacked { --bs-progress-bar-bg: var(--bs-primary); }
.list-group { --bs-list-group-active-bg: var(--bs-primary); --bs-list-group-active-border-color: var(--bs-primary); }
.dropdown-menu { --bs-dropdown-link-active-bg: var(--bs-primary); border-radius: .875rem; box-shadow: var(--wdw-shadow-sm); }
.accordion { --bs-accordion-active-bg: var(--bs-primary-bg-subtle); --bs-accordion-active-color: var(--bs-primary-text-emphasis); --bs-accordion-btn-focus-box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.badge { font-weight: 600; }
/* Library building blocks — use these instead of re-inventing them per snippet. */
.wdw-stage { min-height: 100vh; display: flex; align-items: center; background: var(--wdw-stage); padding-block: 3rem; }
.wdw-card { background: var(--bs-body-bg); border: 1px solid var(--bs-border-color-translucent); border-radius: var(--wdw-radius-card); box-shadow: var(--wdw-shadow); }
.wdw-card-sm { background: var(--bs-body-bg); border: 1px solid var(--bs-border-color-translucent); border-radius: 1rem; box-shadow: var(--wdw-shadow-sm); }
.wdw-aurora { position: relative; color: #fff; background: radial-gradient(60% 55% at 100% 0, #818cf8 0, transparent 70%), radial-gradient(65% 60% at 0 100%, #ec4899 0, transparent 65%), #1e1b4b; }
.wdw-eyebrow { display: inline-block; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--bs-primary); }
.wdw-heading { font-weight: 800; letter-spacing: -.02em; color: var(--bs-emphasis-color); }
.wdw-muted { color: var(--bs-secondary-color); }
.wdw-icon { width: 2.75rem; height: 2.75rem; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: .875rem; background: var(--bs-primary-bg-subtle); color: var(--bs-primary); }
/* Component */
#orders thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--bs-secondary-color); font-weight: 700; padding-block: .85rem; white-space: nowrap; border-bottom-color: var(--bs-border-color); }
#orders td { padding-block: .85rem; }
#orders td, #orders th { white-space: nowrap; }
#orders .ot-num { font-variant-numeric: tabular-nums; }
#orders .ot-av { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; font-size: .75rem; }
#orders .form-check-input { width: 2.5rem; height: 1.35rem; cursor: pointer; }
#orders .form-check-input:indeterminate { background-color: var(--bs-primary); border-color: var(--bs-primary); background-position: center; background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3crect x='-3' y='-.6' width='6' height='1.2' rx='.6' fill='%23fff'/%3e%3c/svg%3e"); }
#orders tbody tr > * { --bs-table-bg: transparent; }
#orders tbody tr.is-selected > * { --bs-table-bg: var(--bs-primary-bg-subtle); }
#orders .ot-more { --bs-btn-bg: transparent; --bs-btn-border-color: transparent; color: var(--bs-secondary-color); }
(function () {
function initOrders() {
var root = document.getElementById('orders');
if (!root) return;
var all = document.getElementById('otAll'), rows = root.querySelectorAll('.ot-row');
var summary = document.getElementById('otSummary'), bulk = document.getElementById('otBulk');
function sync() {
var n = 0;
rows.forEach(function (r) { r.closest('tr').classList.toggle('is-selected', r.checked); if (r.checked) n++; });
all.checked = n === rows.length; all.indeterminate = n > 0 && n < rows.length;
summary.textContent = n === rows.length ? 'All ' + n + ' orders selected' : n ? n + ' of ' + rows.length + ' orders selected' : 'No orders selected';
bulk.disabled = !n;
}
rows.forEach(function (r) { r.addEventListener('change', sync); });
all.addEventListener('change', function () { rows.forEach(function (r) { r.checked = all.checked; }); sync(); });
sync();
}
function initRowMenus() {
document.querySelectorAll('#orders .ot-more').forEach(function (b) {
new bootstrap.Dropdown(b, { popperConfig: { strategy: 'fixed' } });
});
}
initOrders();
initRowMenus();
})();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.