Bootstrap 5 Product Listing with Filters
A product listing with a filter sidebar for category, brand and maximum price, plus sorting, wishlist hearts and add-to-cart buttons. Filters update the grid instantly.
<section class="wdw-stage align-items-start align-items-lg-center"><div class="container" style="max-width:1180px">
<div class="d-flex flex-wrap align-items-end justify-content-between gap-3 mb-4">
<div><span class="wdw-eyebrow">Shop</span><h2 class="wdw-heading mb-0 mt-1">Computers & gear</h2></div>
<div class="d-flex align-items-center gap-2"><span class="wdw-muted small" id="plCount" aria-live="polite">6 products</span>
<label for="plSort" class="visually-hidden">Sort by</label><select id="plSort" class="form-select form-select-sm" style="width:auto;min-height:40px"><option value="feat">Featured</option><option value="low">Price: low to high</option><option value="high">Price: high to low</option></select></div></div>
<div class="row g-4">
<aside class="col-lg-3"><form class="wdw-card p-4 d-flex flex-column gap-4" id="plFilters" aria-label="Product filters">
<fieldset><legend class="wdw-eyebrow mb-2">Category</legend>
<div class="d-flex flex-wrap gap-2">
<input type="radio" class="btn-check" name="cat" id="cat-all" value="" checked><label class="btn btn-sm btn-outline-primary rounded-pill" for="cat-all">All</label>
<input type="radio" class="btn-check" name="cat" id="cat-Laptops" value="Laptops"><label class="btn btn-sm btn-outline-primary rounded-pill" for="cat-Laptops">Laptops</label>
<input type="radio" class="btn-check" name="cat" id="cat-Wearables" value="Wearables"><label class="btn btn-sm btn-outline-primary rounded-pill" for="cat-Wearables">Wearables</label>
<input type="radio" class="btn-check" name="cat" id="cat-Footwear" value="Footwear"><label class="btn btn-sm btn-outline-primary rounded-pill" for="cat-Footwear">Footwear</label>
<input type="radio" class="btn-check" name="cat" id="cat-Audio" value="Audio"><label class="btn btn-sm btn-outline-primary rounded-pill" for="cat-Audio">Audio</label>
<input type="radio" class="btn-check" name="cat" id="cat-Cameras" value="Cameras"><label class="btn btn-sm btn-outline-primary rounded-pill" for="cat-Cameras">Cameras</label>
</div></fieldset>
<fieldset><legend class="wdw-eyebrow mb-2">Brand</legend><div class="d-grid gap-2">
<div class="form-check d-flex justify-content-between ps-0"><div><input class="form-check-input ms-0 me-2" type="checkbox" name="brand" value="Acer" id="b-Acer"><label class="form-check-label" for="b-Acer">Acer</label></div><span class="wdw-muted small">1</span></div>
<div class="form-check d-flex justify-content-between ps-0"><div><input class="form-check-input ms-0 me-2" type="checkbox" name="brand" value="Asus" id="b-Asus"><label class="form-check-label" for="b-Asus">Asus</label></div><span class="wdw-muted small">1</span></div>
<div class="form-check d-flex justify-content-between ps-0"><div><input class="form-check-input ms-0 me-2" type="checkbox" name="brand" value="Dell" id="b-Dell"><label class="form-check-label" for="b-Dell">Dell</label></div><span class="wdw-muted small">1</span></div>
<div class="form-check d-flex justify-content-between ps-0"><div><input class="form-check-input ms-0 me-2" type="checkbox" name="brand" value="Hygen" id="b-Hygen"><label class="form-check-label" for="b-Hygen">Hygen</label></div><span class="wdw-muted small">1</span></div>
<div class="form-check d-flex justify-content-between ps-0"><div><input class="form-check-input ms-0 me-2" type="checkbox" name="brand" value="Polaroid" id="b-Polaroid"><label class="form-check-label" for="b-Polaroid">Polaroid</label></div><span class="wdw-muted small">1</span></div>
<div class="form-check d-flex justify-content-between ps-0"><div><input class="form-check-input ms-0 me-2" type="checkbox" name="brand" value="Nike" id="b-Nike"><label class="form-check-label" for="b-Nike">Nike</label></div><span class="wdw-muted small">1</span></div>
</div></fieldset>
<div><label for="plPrice" class="wdw-eyebrow d-flex justify-content-between mb-2"><span>Max price</span><span id="plPriceOut" class="text-body-emphasis">$2,000</span></label><input type="range" class="form-range" id="plPrice" min="100" max="2000" step="50" value="2000"></div>
<button type="reset" class="btn btn-outline-secondary rounded-pill" id="plReset">Reset filters</button>
</form></aside>
<div class="col-lg-9"><div class="row row-cols-1 row-cols-sm-2 row-cols-xl-3 g-4" id="plGrid">
<div class="col" data-cat="Footwear" data-brand="Nike" data-price="1999.99" data-order="0"><article class="wdw-card h-100 overflow-hidden wdw-product d-flex flex-column">
<div class="position-relative bg-body-tertiary"><img src="https://images.unsplash.com/photo-1542291026-7eec264c27ff?auto=format&fit=crop&w=600&q=75" alt="XRD Active Shoes" class="w-100 object-fit-cover d-block" style="height:200px" loading="lazy"><span class="badge rounded-pill bg-success position-absolute top-0 end-0 m-3">-25%</span></div>
<div class="p-3 p-md-4 d-flex flex-column flex-grow-1"><span class="wdw-muted small">Footwear · Nike</span><h3 class="h6 fw-bold mt-1 mb-2">XRD Active Shoes</h3><p class="fw-bold text-primary mb-3">$1,999.99</p>
<div class="d-flex gap-2 mt-auto"><button type="button" class="btn btn-primary btn-sm rounded-pill flex-grow-1" data-cart>Add to cart</button><button type="button" class="btn btn-outline-secondary btn-sm rounded-circle p-0 flex-none" style="width:36px" data-wish aria-pressed="false" aria-label="Save XRD Active Shoes to wishlist"><i class="bi bi-heart" aria-hidden="true"></i></button></div></div></article></div>
<div class="col" data-cat="Wearables" data-brand="Hygen" data-price="123.43" data-order="1"><article class="wdw-card h-100 overflow-hidden wdw-product d-flex flex-column">
<div class="position-relative bg-body-tertiary"><img src="https://images.unsplash.com/photo-1523275335684-37898b6baf30?auto=format&fit=crop&w=600&q=75" alt="Hygen Smart Watch" class="w-100 object-fit-cover d-block" style="height:200px" loading="lazy"><span class="badge rounded-pill bg-warning text-dark position-absolute top-0 end-0 m-3">Sale</span></div>
<div class="p-3 p-md-4 d-flex flex-column flex-grow-1"><span class="wdw-muted small">Wearables · Hygen</span><h3 class="h6 fw-bold mt-1 mb-2">Hygen Smart Watch</h3><p class="fw-bold text-primary mb-3">$123.43</p>
<div class="d-flex gap-2 mt-auto"><button type="button" class="btn btn-primary btn-sm rounded-pill flex-grow-1" data-cart>Add to cart</button><button type="button" class="btn btn-outline-secondary btn-sm rounded-circle p-0 flex-none" style="width:36px" data-wish aria-pressed="false" aria-label="Save Hygen Smart Watch to wishlist"><i class="bi bi-heart" aria-hidden="true"></i></button></div></div></article></div>
<div class="col" data-cat="Laptops" data-brand="Acer" data-price="1999.99" data-order="2"><article class="wdw-card h-100 overflow-hidden wdw-product d-flex flex-column">
<div class="position-relative bg-body-tertiary"><img src="https://images.unsplash.com/photo-1496181133206-80ce9b88a853?auto=format&fit=crop&w=600&q=75" alt="Acer Surface Book 2.5" class="w-100 object-fit-cover d-block" style="height:200px" loading="lazy"></div>
<div class="p-3 p-md-4 d-flex flex-column flex-grow-1"><span class="wdw-muted small">Laptops · Acer</span><h3 class="h6 fw-bold mt-1 mb-2">Acer Surface Book 2.5</h3><p class="fw-bold text-primary mb-3">$1,999.99</p>
<div class="d-flex gap-2 mt-auto"><button type="button" class="btn btn-primary btn-sm rounded-pill flex-grow-1" data-cart>Add to cart</button><button type="button" class="btn btn-outline-secondary btn-sm rounded-circle p-0 flex-none" style="width:36px" data-wish aria-pressed="false" aria-label="Save Acer Surface Book 2.5 to wishlist"><i class="bi bi-heart" aria-hidden="true"></i></button></div></div></article></div>
<div class="col" data-cat="Laptops" data-brand="Dell" data-price="1245.89" data-order="3"><article class="wdw-card h-100 overflow-hidden wdw-product d-flex flex-column">
<div class="position-relative bg-body-tertiary"><img src="https://images.unsplash.com/photo-1588872657578-7efd1f1555ed?auto=format&fit=crop&w=600&q=75" alt="Dell XPS Surface" class="w-100 object-fit-cover d-block" style="height:200px" loading="lazy"><span class="badge rounded-pill bg-success position-absolute top-0 end-0 m-3">-10%</span></div>
<div class="p-3 p-md-4 d-flex flex-column flex-grow-1"><span class="wdw-muted small">Laptops · Dell</span><h3 class="h6 fw-bold mt-1 mb-2">Dell XPS Surface</h3><p class="fw-bold text-primary mb-3">$1,245.89</p>
<div class="d-flex gap-2 mt-auto"><button type="button" class="btn btn-primary btn-sm rounded-pill flex-grow-1" data-cart>Add to cart</button><button type="button" class="btn btn-outline-secondary btn-sm rounded-circle p-0 flex-none" style="width:36px" data-wish aria-pressed="false" aria-label="Save Dell XPS Surface to wishlist"><i class="bi bi-heart" aria-hidden="true"></i></button></div></div></article></div>
<div class="col" data-cat="Audio" data-brand="Asus" data-price="249.0" data-order="4"><article class="wdw-card h-100 overflow-hidden wdw-product d-flex flex-column">
<div class="position-relative bg-body-tertiary"><img src="https://images.unsplash.com/photo-1505740420928-5e560c06d30e?auto=format&fit=crop&w=600&q=75" alt="Studio Headphones" class="w-100 object-fit-cover d-block" style="height:200px" loading="lazy"></div>
<div class="p-3 p-md-4 d-flex flex-column flex-grow-1"><span class="wdw-muted small">Audio · Asus</span><h3 class="h6 fw-bold mt-1 mb-2">Studio Headphones</h3><p class="fw-bold text-primary mb-3">$249.00</p>
<div class="d-flex gap-2 mt-auto"><button type="button" class="btn btn-primary btn-sm rounded-pill flex-grow-1" data-cart>Add to cart</button><button type="button" class="btn btn-outline-secondary btn-sm rounded-circle p-0 flex-none" style="width:36px" data-wish aria-pressed="false" aria-label="Save Studio Headphones to wishlist"><i class="bi bi-heart" aria-hidden="true"></i></button></div></div></article></div>
<div class="col" data-cat="Cameras" data-brand="Polaroid" data-price="899.0" data-order="5"><article class="wdw-card h-100 overflow-hidden wdw-product d-flex flex-column">
<div class="position-relative bg-body-tertiary"><img src="https://images.unsplash.com/photo-1526170375885-4d8ecf77b99f?auto=format&fit=crop&w=600&q=75" alt="Instant Camera" class="w-100 object-fit-cover d-block" style="height:200px" loading="lazy"><span class="badge rounded-pill bg-success position-absolute top-0 end-0 m-3">-5%</span></div>
<div class="p-3 p-md-4 d-flex flex-column flex-grow-1"><span class="wdw-muted small">Cameras · Polaroid</span><h3 class="h6 fw-bold mt-1 mb-2">Instant Camera</h3><p class="fw-bold text-primary mb-3">$899.00</p>
<div class="d-flex gap-2 mt-auto"><button type="button" class="btn btn-primary btn-sm rounded-pill flex-grow-1" data-cart>Add to cart</button><button type="button" class="btn btn-outline-secondary btn-sm rounded-circle p-0 flex-none" style="width:36px" data-wish aria-pressed="false" aria-label="Save Instant Camera to wishlist"><i class="bi bi-heart" aria-hidden="true"></i></button></div></div></article></div>
</div><div class="wdw-card p-5 text-center d-none" id="plEmpty"><h3 class="h5 fw-bold">No products match</h3><p class="wdw-muted mb-0">Try removing a filter or raising the price limit.</p></div></div></div></div></section>
@import url("https://cdnjs.cloudflare.com/ajax/libs/bootstrap-icons/1.11.3/font/bootstrap-icons.min.css");
/* 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 */
.wdw-product{transition:transform .2s,box-shadow .2s}
.wdw-product:hover{transform:translateY(-3px)}
.wdw-product img{transition:transform .4s}
.wdw-product:hover img{transform:scale(1.04)}
.wdw-product .position-relative{overflow:hidden}
fieldset{border:0;padding:0;margin:0}
legend{float:none;width:auto;padding:0;display:block}
.flex-none{flex:none}
[data-wish][aria-pressed="true"]{color:#dc3545;border-color:#dc3545}
.form-range:focus::-webkit-slider-thumb{box-shadow:0 0 0 .25rem var(--bs-focus-ring-color)}
.form-range::-webkit-slider-thumb{background:var(--bs-primary)}
.form-range::-moz-range-thumb{background:var(--bs-primary)}
@media(prefers-reduced-motion:reduce){.wdw-product,.wdw-product img{transition:none}}
function initProductFilters() {
const form = document.getElementById('plFilters');
const grid = document.getElementById('plGrid');
if (!form || !grid) return;
const items = [...grid.children];
const sort = document.getElementById('plSort');
const price = document.getElementById('plPrice');
const out = document.getElementById('plPriceOut');
const count = document.getElementById('plCount');
const empty = document.getElementById('plEmpty');
const fmt = (n) => '$' + Number(n).toLocaleString('en-US');
const apply = () => {
const cat = form.elements.cat.value;
const brands = [...form.querySelectorAll('[name="brand"]:checked')].map((b) => b.value);
const max = Number(price.value);
out.textContent = fmt(max);
let shown = 0;
items.forEach((el) => {
const ok = (!cat || el.dataset.cat === cat) && (!brands.length || brands.includes(el.dataset.brand)) && Number(el.dataset.price) <= max;
el.classList.toggle('d-none', !ok);
if (ok) shown++;
});
const dir = sort.value;
[...items].sort((a, b) => dir === 'low' ? a.dataset.price - b.dataset.price : dir === 'high' ? b.dataset.price - a.dataset.price : a.dataset.order - b.dataset.order).forEach((el) => grid.appendChild(el));
count.textContent = shown + (shown === 1 ? ' product' : ' products');
empty.classList.toggle('d-none', shown > 0);
};
form.addEventListener('input', apply);
form.addEventListener('reset', () => setTimeout(apply));
sort.addEventListener('change', apply);
}
function initProductActions() {
const grid = document.getElementById('plGrid');
if (!grid) return;
grid.addEventListener('click', (e) => {
const wish = e.target.closest('[data-wish]');
if (wish) {
const on = wish.getAttribute('aria-pressed') !== 'true';
wish.setAttribute('aria-pressed', on);
wish.firstElementChild.className = on ? 'bi bi-heart-fill' : 'bi bi-heart';
}
const cart = e.target.closest('[data-cart]');
if (cart) {
cart.textContent = 'Added ✓';
setTimeout(() => { cart.textContent = 'Add to cart'; }, 1400);
}
});
}
initProductFilters();
initProductActions();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.