Bootstrap 5 Blog Card Carousel
A swipeable blog card carousel with image cards, category labels, comment counts, arrow buttons and page dots.
<section class="wdw-stage">
<div class="container" style="max-width:1100px">
<div class="d-flex align-items-end justify-content-between gap-3 mb-4">
<div>
<span class="wdw-eyebrow mb-2">From the blog</span>
<h1 class="wdw-heading h2 mb-0">Fresh reads this month</h1>
</div>
<div class="d-flex gap-2">
<button type="button" class="btn btn-outline-primary rounded-circle p-0 bc-nav" id="bcPrev" aria-label="Previous posts"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 18l-6-6 6-6"/></svg></button>
<button type="button" class="btn btn-outline-primary rounded-circle p-0 bc-nav" id="bcNext" aria-label="Next posts"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 18l6-6-6-6"/></svg></button>
</div>
</div>
<div class="bc" id="blogCarousel" role="region" aria-roledescription="carousel" aria-label="Latest blog posts">
<div class="bc-track" id="bcTrack" tabindex="0">
<article class="bc-slide" role="group" aria-roledescription="slide" aria-label="1 of 6">
<div class="wdw-card h-100 overflow-hidden d-flex flex-column">
<div class="position-relative">
<img src="https://images.unsplash.com/photo-1486312338219-ce68d2c6f44d?auto=format&fit=crop&w=720&h=450&q=70" alt="" class="bc-img w-100" width="720" height="450" loading="lazy">
<span class="badge rounded-pill bg-body text-body-emphasis position-absolute top-0 start-0 m-3 shadow-sm">Aug 01</span>
</div>
<div class="p-4 d-flex flex-column flex-grow-1">
<span class="wdw-eyebrow mb-2">Productivity</span>
<h3 class="h5 fw-bold mb-2">Designing a desk setup that keeps you focused</h3>
<p class="wdw-muted small mb-3">Small, deliberate changes to your workspace that cut distraction and make long sessions easier.</p>
<div class="d-flex align-items-center justify-content-between mt-auto">
<span class="small wdw-muted">3 comments</span>
<a href="#" class="link-primary fw-semibold text-decoration-none small stretched-link">Read more →</a>
</div>
</div>
</div>
</article>
<article class="bc-slide" role="group" aria-roledescription="slide" aria-label="2 of 6">
<div class="wdw-card h-100 overflow-hidden d-flex flex-column">
<div class="position-relative">
<img src="https://images.unsplash.com/photo-1460925895917-afdab827c52f?auto=format&fit=crop&w=720&h=450&q=70" alt="" class="bc-img w-100" width="720" height="450" loading="lazy">
<span class="badge rounded-pill bg-body text-body-emphasis position-absolute top-0 start-0 m-3 shadow-sm">Aug 08</span>
</div>
<div class="p-4 d-flex flex-column flex-grow-1">
<span class="wdw-eyebrow mb-2">Analytics</span>
<h3 class="h5 fw-bold mb-2">Reading your metrics without the noise</h3>
<p class="wdw-muted small mb-3">Which numbers matter, which are vanity, and how to build a weekly review you will keep.</p>
<div class="d-flex align-items-center justify-content-between mt-auto">
<span class="small wdw-muted">8 comments</span>
<a href="#" class="link-primary fw-semibold text-decoration-none small stretched-link">Read more →</a>
</div>
</div>
</div>
</article>
<article class="bc-slide" role="group" aria-roledescription="slide" aria-label="3 of 6">
<div class="wdw-card h-100 overflow-hidden d-flex flex-column">
<div class="position-relative">
<img src="https://images.unsplash.com/photo-1517694712202-14dd9538aa97?auto=format&fit=crop&w=720&h=450&q=70" alt="" class="bc-img w-100" width="720" height="450" loading="lazy">
<span class="badge rounded-pill bg-body text-body-emphasis position-absolute top-0 start-0 m-3 shadow-sm">Aug 15</span>
</div>
<div class="p-4 d-flex flex-column flex-grow-1">
<span class="wdw-eyebrow mb-2">Development</span>
<h3 class="h5 fw-bold mb-2">Shipping faster with smaller pull requests</h3>
<p class="wdw-muted small mb-3">A simple team agreement that shortens review time and reduces risky releases.</p>
<div class="d-flex align-items-center justify-content-between mt-auto">
<span class="small wdw-muted">5 comments</span>
<a href="#" class="link-primary fw-semibold text-decoration-none small stretched-link">Read more →</a>
</div>
</div>
</div>
</article>
<article class="bc-slide" role="group" aria-roledescription="slide" aria-label="4 of 6">
<div class="wdw-card h-100 overflow-hidden d-flex flex-column">
<div class="position-relative">
<img src="https://images.unsplash.com/photo-1504384308090-c894fdcc538d?auto=format&fit=crop&w=720&h=450&q=70" alt="" class="bc-img w-100" width="720" height="450" loading="lazy">
<span class="badge rounded-pill bg-body text-body-emphasis position-absolute top-0 start-0 m-3 shadow-sm">Aug 22</span>
</div>
<div class="p-4 d-flex flex-column flex-grow-1">
<span class="wdw-eyebrow mb-2">Teamwork</span>
<h3 class="h5 fw-bold mb-2">Run a retrospective that leads to change</h3>
<p class="wdw-muted small mb-3">Formats that surface real problems and turn them into one or two clear actions.</p>
<div class="d-flex align-items-center justify-content-between mt-auto">
<span class="small wdw-muted">2 comments</span>
<a href="#" class="link-primary fw-semibold text-decoration-none small stretched-link">Read more →</a>
</div>
</div>
</div>
</article>
<article class="bc-slide" role="group" aria-roledescription="slide" aria-label="5 of 6">
<div class="wdw-card h-100 overflow-hidden d-flex flex-column">
<div class="position-relative">
<img src="https://images.unsplash.com/photo-1531297484001-80022131f5a1?auto=format&fit=crop&w=720&h=450&q=70" alt="" class="bc-img w-100" width="720" height="450" loading="lazy">
<span class="badge rounded-pill bg-body text-body-emphasis position-absolute top-0 start-0 m-3 shadow-sm">Aug 29</span>
</div>
<div class="p-4 d-flex flex-column flex-grow-1">
<span class="wdw-eyebrow mb-2">Tools</span>
<h3 class="h5 fw-bold mb-2">The lightweight stack behind our content workflow</h3>
<p class="wdw-muted small mb-3">From idea backlog to published post, using tools you probably already pay for.</p>
<div class="d-flex align-items-center justify-content-between mt-auto">
<span class="small wdw-muted">6 comments</span>
<a href="#" class="link-primary fw-semibold text-decoration-none small stretched-link">Read more →</a>
</div>
</div>
</div>
</article>
<article class="bc-slide" role="group" aria-roledescription="slide" aria-label="6 of 6">
<div class="wdw-card h-100 overflow-hidden d-flex flex-column">
<div class="position-relative">
<img src="https://images.unsplash.com/photo-1555066931-4365d14bab8c?auto=format&fit=crop&w=720&h=450&q=70" alt="" class="bc-img w-100" width="720" height="450" loading="lazy">
<span class="badge rounded-pill bg-body text-body-emphasis position-absolute top-0 start-0 m-3 shadow-sm">Sep 05</span>
</div>
<div class="p-4 d-flex flex-column flex-grow-1">
<span class="wdw-eyebrow mb-2">Code</span>
<h3 class="h5 fw-bold mb-2">Writing CSS that is still readable in a year</h3>
<p class="wdw-muted small mb-3">Naming, layering and tokens that keep a growing stylesheet under control.</p>
<div class="d-flex align-items-center justify-content-between mt-auto">
<span class="small wdw-muted">4 comments</span>
<a href="#" class="link-primary fw-semibold text-decoration-none small stretched-link">Read more →</a>
</div>
</div>
</div>
</article>
</div>
</div>
<div class="d-flex justify-content-center gap-2 mt-4" id="bcDots" role="group" aria-label="Choose slide group"></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 */
.bc-track { display: flex; gap: 1.5rem; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; padding: .5rem .5rem 3rem; margin: -.5rem -.5rem -2rem; }
.bc-track::-webkit-scrollbar { display: none; }
.bc-track:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 2px; border-radius: 1rem; }
.bc-slide { flex: 0 0 calc((100% - 3rem) / 3); scroll-snap-align: start; }
@media (max-width: 991.98px) { .bc-slide { flex-basis: calc((100% - 1.5rem) / 2); } }
@media (max-width: 575.98px) { .bc-slide { flex-basis: 86%; } }
.bc-img { aspect-ratio: 16/10; height: auto; object-fit: cover; }
.bc-slide .wdw-card { transition: transform .2s ease, box-shadow .2s ease; }
.bc-slide:hover .wdw-card { transform: translateY(-3px); }
.bc-nav { width: 44px; height: 44px; min-height: 44px; }
.bc-dot { width: 10px; height: 10px; min-height: 0; padding: 0; border: 0; border-radius: 999px; background: var(--bs-border-color); transition: width .25s ease, background .25s ease; position: relative; }
.bc-dot::after { content: ""; position: absolute; inset: -17px -4px; }
.bc-dot.is-active { width: 28px; background: var(--bs-primary); }
.bc-dot:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .bc-slide .wdw-card, .bc-dot { transition: none; } }
(function () {
function initBlogCarousel() {
var track = document.getElementById('bcTrack');
var prev = document.getElementById('bcPrev');
var next = document.getElementById('bcNext');
var dotsWrap = document.getElementById('bcDots');
if (!track || !prev || !next || !dotsWrap) return;
var slides = track.children;
var dots = [];
function perView() { return Math.max(1, Math.round(track.clientWidth / slides[0].getBoundingClientRect().width)); }
function step() { return slides[0].getBoundingClientRect().width + parseFloat(getComputedStyle(track).columnGap || 0); }
function pages() { return Math.max(1, Math.ceil((slides.length - perView()) / perView()) + 1); }
function build() {
dotsWrap.innerHTML = ''; dots = [];
for (var i = 0; i < pages(); i++) {
var b = document.createElement('button');
b.type = 'button'; b.className = 'bc-dot'; b.setAttribute('aria-label', 'Go to group ' + (i + 1));
(function (n) { b.addEventListener('click', function () { track.scrollTo({ left: n * perView() * step(), behavior: 'smooth' }); }); })(i);
dotsWrap.appendChild(b); dots.push(b);
}
update();
}
function update() {
var max = track.scrollWidth - track.clientWidth;
var atEnd = track.scrollLeft >= max - 4;
var idx = atEnd ? dots.length - 1 : Math.min(dots.length - 1, Math.round(track.scrollLeft / (perView() * step())));
dots.forEach(function (d, i) { d.classList.toggle('is-active', i === idx); if (i === idx) d.setAttribute('aria-current', 'true'); else d.removeAttribute('aria-current'); });
prev.disabled = track.scrollLeft <= 4;
next.disabled = atEnd;
}
prev.addEventListener('click', function () { track.scrollBy({ left: -perView() * step(), behavior: 'smooth' }); });
next.addEventListener('click', function () { track.scrollBy({ left: perView() * step(), behavior: 'smooth' }); });
track.addEventListener('scroll', function () { window.requestAnimationFrame(update); }, { passive: true });
track.addEventListener('keydown', function (e) {
if (e.key === 'ArrowRight') { e.preventDefault(); next.click(); }
if (e.key === 'ArrowLeft') { e.preventDefault(); prev.click(); }
});
window.addEventListener('resize', build);
build();
}
initBlogCarousel();
})();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.