Bootstrap 5 Carousel with Multiple Items per Slide
A responsive carousel that shows three destination cards per slide on desktop, two on tablets and one on phones, with round arrow buttons, pill indicators and touch swiping.
<section class="wdw-stage">
<div class="container mc-wrap">
<div class="d-flex flex-column flex-sm-row align-items-sm-end justify-content-between gap-3 mb-4">
<div>
<span class="wdw-eyebrow mb-1">Destinations</span>
<h2 class="h2 wdw-heading mb-0">Places worth the trip</h2>
</div>
<div class="d-flex gap-2">
<button class="btn btn-outline-secondary mc-arrow rounded-circle" type="button" data-bs-target="#mc-carousel" data-bs-slide="prev" aria-label="Previous slide"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.200" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 5l-7 7 7 7"/></svg></button>
<button class="btn btn-outline-secondary mc-arrow rounded-circle" type="button" data-bs-target="#mc-carousel" data-bs-slide="next" aria-label="Next slide"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.200" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 5l7 7-7 7"/></svg></button>
</div>
</div>
<div id="mc-carousel" class="carousel slide" aria-roledescription="carousel" aria-label="Featured destinations">
<div class="carousel-inner" id="mc-inner"></div>
<div class="carousel-indicators mc-dots position-static mt-4 mb-0 mx-0 justify-content-center" id="mc-dots"></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 */
.mc-wrap{max-width:1080px}
.mc-arrow{width:44px;height:44px;padding:0;display:inline-flex;align-items:center;justify-content:center;background:var(--bs-body-bg)}
.mc-card{display:block;position:relative;overflow:hidden;color:#fff;text-decoration:none;aspect-ratio:4/5}
.mc-card img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;transition:transform .5s ease}
.mc-card:hover img{transform:scale(1.06)}
.mc-card::after{content:"";position:absolute;inset:0;background:linear-gradient(transparent 45%,rgba(0,0,0,.75))}
.mc-card .mc-cap{position:absolute;left:0;right:0;bottom:0;padding:1.25rem;z-index:1}
.mc-card:focus-visible{outline:3px solid var(--bs-primary);outline-offset:3px}
.mc-dots [data-bs-target]{width:8px;height:8px;border-radius:50%;border:0;background-color:var(--bs-secondary-color);opacity:.4;margin:0 4px;padding:0}
.mc-dots .active{opacity:1;background-color:var(--bs-primary);width:24px;border-radius:8px}
@media (prefers-reduced-motion:reduce){.mc-card img{transition:none}}
function initMultiItemCarousel() {
const el = document.getElementById('mc-carousel');
const inner = document.getElementById('mc-inner');
const dots = document.getElementById('mc-dots');
if (!el || !inner || !dots) return;
const places = [
{ t: 'Dolomites', c: 'Italy', i: '1506905925346-21bda4d32df4' },
{ t: 'Lake Louise', c: 'Canada', i: '1501785888041-af3ef285b470' },
{ t: 'Cascade Forest', c: 'USA', i: '1441974231531-c6227db76b6e' },
{ t: 'Green Valley', c: 'Switzerland', i: '1469474968028-56623f02e42e' },
{ t: 'Maldives', c: 'Indian Ocean', i: '1507525428034-b723cf961d3e' },
{ t: 'Northern Peaks', c: 'Norway', i: '1519681393784-d120267933ba' }
];
let perSlide = 0;
let instance = null;
const visibleCount = () => (window.innerWidth >= 992 ? 3 : window.innerWidth >= 576 ? 2 : 1);
const card = (p) =>
'<div class="col"><a href="#" class="mc-card rounded-4 shadow-sm"><img loading="lazy" src="https://images.unsplash.com/photo-' + p.i +
'?w=600&h=750&fit=crop&q=80" alt="' + p.t + ', ' + p.c + '"><div class="mc-cap"><div class="small opacity-75">' + p.c +
'</div><h3 class="h5 fw-bold mb-0">' + p.t + '</h3></div></a></div>';
const build = () => {
const n = visibleCount();
if (n === perSlide) return;
perSlide = n;
if (instance) instance.dispose();
inner.innerHTML = '';
dots.innerHTML = '';
const slides = Math.ceil(places.length / n);
for (let s = 0; s < slides; s++) {
const group = places.slice(s * n, s * n + n);
const item = document.createElement('div');
item.className = 'carousel-item' + (s === 0 ? ' active' : '');
item.setAttribute('role', 'group');
item.setAttribute('aria-label', (s + 1) + ' of ' + slides);
item.innerHTML = '<div class="row g-3 row-cols-' + n + '">' + group.map(card).join('') + '</div>';
inner.appendChild(item);
const b = document.createElement('button');
b.type = 'button';
b.setAttribute('data-bs-target', '#mc-carousel');
b.setAttribute('data-bs-slide-to', s);
b.setAttribute('aria-label', 'Slide ' + (s + 1));
if (s === 0) { b.className = 'active'; b.setAttribute('aria-current', 'true'); }
dots.appendChild(b);
}
instance = new bootstrap.Carousel(el, { interval: false, touch: true });
};
build();
let t;
window.addEventListener('resize', () => { clearTimeout(t); t = setTimeout(build, 150); });
}
initMultiItemCarousel();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.