Bootstrap 5 Coverflow Image Carousel with Indicators
A 3D coverflow photo carousel with captions, previous and next buttons, dot indicators, keyboard arrows and swipe.
<section class="wdw-stage overflow-hidden"><div class="container" style="max-width:1000px">
<div class="text-center mb-4"><span class="wdw-eyebrow">Gallery</span><h2 class="wdw-heading h2 mb-1">Places worth the trip</h2><p class="wdw-muted mb-0">Use the arrows, swipe, or click a side card.</p></div>
<div class="coverflow" id="coverflow" role="region" aria-roledescription="carousel" aria-label="Travel photos" tabindex="0">
<div class="cf-track">
<figure class="cf-item" role="group" aria-roledescription="slide" aria-label="1 of 7"><img src="https://images.unsplash.com/photo-1506744038136-46273834b3fb?auto=format&fit=crop&w=720&h=720&q=75" width="360" height="360" alt="Alpine Dawn, Switzerland" draggable="false"><figcaption><strong>Alpine Dawn</strong><span>Switzerland</span></figcaption></figure>
<figure class="cf-item" role="group" aria-roledescription="slide" aria-label="2 of 7"><img src="https://images.unsplash.com/photo-1441974231531-c6227db76b6e?auto=format&fit=crop&w=720&h=720&q=75" width="360" height="360" alt="Forest Light, Pacific Northwest" draggable="false"><figcaption><strong>Forest Light</strong><span>Pacific Northwest</span></figcaption></figure>
<figure class="cf-item" role="group" aria-roledescription="slide" aria-label="3 of 7"><img src="https://images.unsplash.com/photo-1469474968028-56623f02e42e?auto=format&fit=crop&w=720&h=720&q=75" width="360" height="360" alt="Golden Coast, Portugal" draggable="false"><figcaption><strong>Golden Coast</strong><span>Portugal</span></figcaption></figure>
<figure class="cf-item" role="group" aria-roledescription="slide" aria-label="4 of 7"><img src="https://images.unsplash.com/photo-1501785888041-af3ef285b470?auto=format&fit=crop&w=720&h=720&q=75" width="360" height="360" alt="Mountain Lake, Canadian Rockies" draggable="false"><figcaption><strong>Mountain Lake</strong><span>Canadian Rockies</span></figcaption></figure>
<figure class="cf-item" role="group" aria-roledescription="slide" aria-label="5 of 7"><img src="https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05?auto=format&fit=crop&w=720&h=720&q=75" width="360" height="360" alt="Open Road, Montana" draggable="false"><figcaption><strong>Open Road</strong><span>Montana</span></figcaption></figure>
<figure class="cf-item" role="group" aria-roledescription="slide" aria-label="6 of 7"><img src="https://images.unsplash.com/photo-1464822759023-fed622ff2c3b?auto=format&fit=crop&w=720&h=720&q=75" width="360" height="360" alt="Highland Mist, Scotland" draggable="false"><figcaption><strong>Highland Mist</strong><span>Scotland</span></figcaption></figure>
<figure class="cf-item" role="group" aria-roledescription="slide" aria-label="7 of 7"><img src="https://images.unsplash.com/photo-1519681393784-d120267933ba?auto=format&fit=crop&w=720&h=720&q=75" width="360" height="360" alt="Quiet Valley, Norway" draggable="false"><figcaption><strong>Quiet Valley</strong><span>Norway</span></figcaption></figure>
</div></div>
<div class="d-flex align-items-center justify-content-center gap-3 mt-4"><button class="btn btn-outline-primary rounded-circle p-0" style="width:44px" type="button" id="cfPrev" aria-label="Previous photo"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 18l-6-6 6-6"/></svg></button><div class="d-flex gap-2" id="cfDots" role="tablist" aria-label="Choose photo"></div><button class="btn btn-outline-primary rounded-circle p-0" style="width:44px" type="button" id="cfNext" aria-label="Next photo"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 18l6-6-6-6"/></svg></button></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 */
.coverflow { position: relative; height: 380px; perspective: 1200px; outline: none; touch-action: pan-y; }
.coverflow:focus-visible { box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); border-radius: 1rem; }
.cf-track { position: absolute; inset: 0; transform-style: preserve-3d; }
.cf-item { --o: 0; --a: 1; position: absolute; left: 50%; top: 50%; width: min(300px, 62vw); aspect-ratio: 1; margin: 0; border-radius: 1.25rem; overflow: hidden; cursor: pointer;
transform: translate(-50%, -50%) translateX(calc(var(--o) * 54%)) translateZ(calc(var(--ao) * -90px)) rotateY(calc(var(--o) * -14deg)) scale(calc(1 - var(--ao) * .1));
opacity: var(--a); z-index: calc(10 - var(--ao)); transition: transform .5s cubic-bezier(.2, .8, .2, 1), opacity .4s; box-shadow: var(--wdw-shadow); background: var(--bs-secondary-bg); }
.cf-item img { width: 100%; height: 100%; object-fit: cover; display: block; user-select: none; }
.cf-item figcaption { position: absolute; inset: auto 0 0 0; padding: 2.5rem 1rem .9rem; color: #fff; display: flex; flex-direction: column; background: linear-gradient(transparent, rgba(8, 8, 20, .72)); opacity: 0; transition: opacity .3s; }
.cf-item figcaption span { font-size: .8rem; opacity: .85; }
.cf-item.is-active { cursor: default; }
.cf-item.is-active figcaption { opacity: 1; }
.cf-item[data-hidden="true"] { pointer-events: none; }
.cf-dot { width: 10px; height: 10px; padding: 0; border: 0; border-radius: 50%; background: var(--bs-border-color); transition: width .25s, background .25s; position: relative; }
.cf-dot::after { content: ""; position: absolute; inset: -17px -4px; }
.cf-dot[aria-selected="true"] { width: 28px; border-radius: 99px; background: var(--bs-primary); }
@media (max-width: 575.98px) { .coverflow { height: 300px; } .cf-item { width: 62vw; transform: translate(-50%, -50%) translateX(calc(var(--o) * 58%)) translateZ(calc(var(--ao) * -90px)) rotateY(calc(var(--o) * -14deg)) scale(calc(1 - var(--ao) * .1)); } }
@media (prefers-reduced-motion: reduce) { .cf-item { transition: none; } }
function initCoverflow() {
const root = document.getElementById('coverflow');
if (!root) return;
const items = Array.from(root.querySelectorAll('.cf-item'));
const dotsHost = document.getElementById('cfDots');
const n = items.length;
let cur = Math.floor(n / 2);
const dots = items.map((_, i) => {
const b = document.createElement('button');
b.type = 'button';
b.className = 'cf-dot';
b.setAttribute('role', 'tab');
b.setAttribute('aria-label', 'Photo ' + (i + 1));
b.addEventListener('click', () => go(i));
dotsHost.appendChild(b);
return b;
});
function render() {
items.forEach((el, i) => {
const o = i - cur, ao = Math.abs(o);
el.style.setProperty('--o', Math.max(-3, Math.min(3, o)));
el.style.setProperty('--ao', Math.min(ao, 3));
el.style.setProperty('--a', ao > 2 ? 0 : ao === 2 ? 0.55 : 1);
el.dataset.hidden = ao > 2 ? 'true' : 'false';
el.classList.toggle('is-active', o === 0);
el.setAttribute('aria-hidden', o === 0 ? 'false' : 'true');
});
dots.forEach((d, i) => d.setAttribute('aria-selected', i === cur ? 'true' : 'false'));
}
function go(i) { cur = Math.max(0, Math.min(n - 1, i)); render(); }
document.getElementById('cfPrev').addEventListener('click', () => go(cur - 1));
document.getElementById('cfNext').addEventListener('click', () => go(cur + 1));
items.forEach((el, i) => el.addEventListener('click', () => go(i)));
root.addEventListener('keydown', (e) => {
if (e.key === 'ArrowLeft') { e.preventDefault(); go(cur - 1); }
if (e.key === 'ArrowRight') { e.preventDefault(); go(cur + 1); }
});
let sx = null;
root.addEventListener('pointerdown', (e) => { sx = e.clientX; });
root.addEventListener('pointerup', (e) => {
if (sx === null) return;
const dx = e.clientX - sx;
sx = null;
if (Math.abs(dx) > 40) go(cur + (dx < 0 ? 1 : -1));
});
render();
}
initCoverflow();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.