Bootstrap 5 News Cards Grid with Category Filter
A responsive grid of news story cards with image, category badge, headline, excerpt and byline. Filter pills narrow the list by topic.
<section class="wdw-stage">
<div class="container w-100" style="max-width:1120px">
<div class="d-flex flex-column flex-md-row justify-content-between align-items-md-end gap-3 mb-4">
<div>
<span class="wdw-eyebrow">Newsfeed</span>
<h2 class="wdw-heading h2 mb-0">Latest in tech</h2>
</div>
<div class="d-flex flex-wrap gap-2" id="news-filters" role="group" aria-label="Filter stories">
<button type="button" class="btn btn-sm btn-primary rounded-pill" data-filter="all" aria-pressed="true">All</button>
<button type="button" class="btn btn-sm btn-outline-secondary rounded-pill" data-filter="Audio" aria-pressed="false">Audio</button>
<button type="button" class="btn btn-sm btn-outline-secondary rounded-pill" data-filter="Camera" aria-pressed="false">Camera</button>
<button type="button" class="btn btn-sm btn-outline-secondary rounded-pill" data-filter="Hardware" aria-pressed="false">Hardware</button>
<button type="button" class="btn btn-sm btn-outline-secondary rounded-pill" data-filter="Laptops" aria-pressed="false">Laptops</button>
<button type="button" class="btn btn-sm btn-outline-secondary rounded-pill" data-filter="Energy" aria-pressed="false">Energy</button>
</div>
</div>
<div class="row row-cols-1 row-cols-sm-2 row-cols-lg-3 g-4" id="news-grid">
<div class="col" data-cat="Camera">
<article class="card news-card h-100 border-0 wdw-card-sm overflow-hidden">
<div class="ratio ratio-16x9 overflow-hidden"><img src="https://images.unsplash.com/photo-1516035069371-29a1b244cc32?auto=format&fit=crop&w=720&q=70" alt="" loading="lazy" class="object-fit-cover"></div>
<div class="card-body p-4 d-flex flex-column">
<span class="badge rounded-pill bg-primary-subtle text-primary-emphasis align-self-start mb-3">Camera</span>
<h3 class="h5 fw-bold mb-2"><a href="#" class="stretched-link text-body-emphasis text-decoration-none">Canon unveils a compact servo telephoto zoom</a></h3>
<p class="text-body-secondary small mb-3">A new 70-200mm lens brings smooth, quiet zoom to run-and-gun shooters and small crews.</p>
<p class="small text-body-secondary mt-auto mb-0">Maya Chen · 3 mins ago</p>
</div>
</article>
</div>
<div class="col" data-cat="Audio">
<article class="card news-card h-100 border-0 wdw-card-sm overflow-hidden">
<div class="ratio ratio-16x9 overflow-hidden"><img src="https://images.unsplash.com/photo-1505740420928-5e560c06d30e?auto=format&fit=crop&w=720&q=70" alt="" loading="lazy" class="object-fit-cover"></div>
<div class="card-body p-4 d-flex flex-column">
<span class="badge rounded-pill bg-primary-subtle text-primary-emphasis align-self-start mb-3">Audio</span>
<h3 class="h5 fw-bold mb-2"><a href="#" class="stretched-link text-body-emphasis text-decoration-none">Sennheiser HD 598 specs, tested and explained</a></h3>
<p class="text-body-secondary small mb-3">Open-back comfort and a warm, wide soundstage: what the numbers say and what you will hear.</p>
<p class="small text-body-secondary mt-auto mb-0">Leo Park · 1 hour ago</p>
</div>
</article>
</div>
<div class="col" data-cat="Energy">
<article class="card news-card h-100 border-0 wdw-card-sm overflow-hidden">
<div class="ratio ratio-16x9 overflow-hidden"><img src="https://images.unsplash.com/photo-1466611653911-95081537e5b7?auto=format&fit=crop&w=720&q=70" alt="" loading="lazy" class="object-fit-cover"></div>
<div class="card-body p-4 d-flex flex-column">
<span class="badge rounded-pill bg-primary-subtle text-primary-emphasis align-self-start mb-3">Energy</span>
<h3 class="h5 fw-bold mb-2"><a href="#" class="stretched-link text-body-emphasis text-decoration-none">North Sea wind hub is set to power millions of homes</a></h3>
<p class="text-body-secondary small mb-3">Offshore turbines and an artificial island will link several countries to one shared grid.</p>
<p class="small text-body-secondary mt-auto mb-0">Sara Novak · 3 hours ago</p>
</div>
</article>
</div>
<div class="col" data-cat="Laptops">
<article class="card news-card h-100 border-0 wdw-card-sm overflow-hidden">
<div class="ratio ratio-16x9 overflow-hidden"><img src="https://images.unsplash.com/photo-1498050108023-c5249f4df085?auto=format&fit=crop&w=720&q=70" alt="" loading="lazy" class="object-fit-cover"></div>
<div class="card-body p-4 d-flex flex-column">
<span class="badge rounded-pill bg-primary-subtle text-primary-emphasis align-self-start mb-3">Laptops</span>
<h3 class="h5 fw-bold mb-2"><a href="#" class="stretched-link text-body-emphasis text-decoration-none">Why the thin-and-light laptop is finally fast enough</a></h3>
<p class="text-body-secondary small mb-3">Efficient chips and better cooling have closed the gap with bulkier workstations.</p>
<p class="small text-body-secondary mt-auto mb-0">Jon Ellis · Yesterday</p>
</div>
</article>
</div>
<div class="col" data-cat="Hardware">
<article class="card news-card h-100 border-0 wdw-card-sm overflow-hidden">
<div class="ratio ratio-16x9 overflow-hidden"><img src="https://images.unsplash.com/photo-1518770660439-4636190af475?auto=format&fit=crop&w=720&q=70" alt="" loading="lazy" class="object-fit-cover"></div>
<div class="card-body p-4 d-flex flex-column">
<span class="badge rounded-pill bg-primary-subtle text-primary-emphasis align-self-start mb-3">Hardware</span>
<h3 class="h5 fw-bold mb-2"><a href="#" class="stretched-link text-body-emphasis text-decoration-none">Inside the next generation of low-power chips</a></h3>
<p class="text-body-secondary small mb-3">Smaller nodes, stacked memory and smarter scheduling are changing what a watt can do.</p>
<p class="small text-body-secondary mt-auto mb-0">Maya Chen · Yesterday</p>
</div>
</article>
</div>
<div class="col" data-cat="Audio">
<article class="card news-card h-100 border-0 wdw-card-sm overflow-hidden">
<div class="ratio ratio-16x9 overflow-hidden"><img src="https://images.unsplash.com/photo-1583394838336-acd977736f90?auto=format&fit=crop&w=720&q=70" alt="" loading="lazy" class="object-fit-cover"></div>
<div class="card-body p-4 d-flex flex-column">
<span class="badge rounded-pill bg-primary-subtle text-primary-emphasis align-self-start mb-3">Audio</span>
<h3 class="h5 fw-bold mb-2"><a href="#" class="stretched-link text-body-emphasis text-decoration-none">Studio headphones that finally break the mould</a></h3>
<p class="text-body-secondary small mb-3">A fresh take on closed-back design, built for long sessions and fast travel.</p>
<p class="small text-body-secondary mt-auto mb-0">Leo Park · 2 days ago</p>
</div>
</article>
</div>
</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 */
.news-card{transition:transform .2s,box-shadow .2s}
.news-card:hover{transform:translateY(-4px);box-shadow:var(--wdw-shadow)!important}
.news-card img{transition:transform .5s}
.news-card:hover img{transform:scale(1.05)}
.news-card .card-body h3 a:hover{color:var(--bs-primary)!important}
#news-filters .btn-primary{color:#fff}
[data-bs-theme="dark"] #news-filters .btn-primary{color:#0f1117}
@media (prefers-reduced-motion:reduce){.news-card,.news-card img{transition:none}}
(function () {
function initNewsFilter() {
var bar = document.getElementById('news-filters');
var grid = document.getElementById('news-grid');
if (!bar || !grid) return;
bar.addEventListener('click', function (e) {
var btn = e.target.closest('button[data-filter]');
if (!btn) return;
var f = btn.dataset.filter;
bar.querySelectorAll('button').forEach(function (b) {
var on = b === btn;
b.setAttribute('aria-pressed', on);
b.classList.toggle('btn-primary', on);
b.classList.toggle('btn-outline-secondary', !on);
});
grid.querySelectorAll('[data-cat]').forEach(function (c) {
c.hidden = !(f === 'all' || c.dataset.cat === f);
});
});
}
initNewsFilter();
})();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.