Bootstrap 5 Testimonial Carousel with Side Previews
A testimonial carousel that centres the active quote card and previews the previous and next ones, with arrows, dots, swipe and keyboard control.
<section class="wdw-stage overflow-hidden">
<div class="container" style="max-width: 1100px;">
<div class="text-center mb-4">
<span class="wdw-eyebrow">Testimonials</span>
<h1 class="wdw-heading h2 mt-1 mb-0">What our clients say</h1>
</div>
<div class="tc" id="tc" role="region" aria-roledescription="carousel" aria-label="Client testimonials" tabindex="0">
<div class="tc-viewport">
<div class="tc-track" id="tc-track">
<figure class="tc-slide m-0" role="group" aria-roledescription="slide" aria-label="1 of 5">
<div class="wdw-card tc-card text-center p-4 p-md-4">
<img class="tc-avatar" src="https://i.pravatar.cc/160?img=47" width="72" height="72" alt="Marielle Haag">
<div class="tc-stars" aria-label="5 out of 5 stars">★★★★★</div>
<blockquote class="mb-3 tc-quote">“Switching took an afternoon and our onboarding time dropped by half. The team genuinely listens to feedback.”</blockquote>
<figcaption><span class="d-block fw-bold">Marielle Haag</span><span class="small wdw-muted">Product designer, Lumen</span></figcaption>
</div>
</figure>
<figure class="tc-slide m-0" role="group" aria-roledescription="slide" aria-label="2 of 5">
<div class="wdw-card tc-card text-center p-4 p-md-4">
<img class="tc-avatar" src="https://i.pravatar.cc/160?img=44" width="72" height="72" alt="Ximena Vegara">
<div class="tc-stars" aria-label="5 out of 5 stars">★★★★★</div>
<blockquote class="mb-3 tc-quote">“The cleanest tooling we have used in years. Reporting that used to take a day now takes a coffee break.”</blockquote>
<figcaption><span class="d-block fw-bold">Ximena Vegara</span><span class="small wdw-muted">Head of Growth, Orbit</span></figcaption>
</div>
</figure>
<figure class="tc-slide m-0" role="group" aria-roledescription="slide" aria-label="3 of 5">
<div class="wdw-card tc-card text-center p-4 p-md-4">
<img class="tc-avatar" src="https://i.pravatar.cc/160?img=12" width="72" height="72" alt="John Paul">
<div class="tc-stars" aria-label="5 out of 5 stars">★★★★★</div>
<blockquote class="mb-3 tc-quote">“Reliable, fast and thoughtfully designed. Our engineers stopped complaining about the stack, which says a lot.”</blockquote>
<figcaption><span class="d-block fw-bold">John Paul</span><span class="small wdw-muted">CTO, Fieldnote</span></figcaption>
</div>
</figure>
<figure class="tc-slide m-0" role="group" aria-roledescription="slide" aria-label="4 of 5">
<div class="wdw-card tc-card text-center p-4 p-md-4">
<img class="tc-avatar" src="https://i.pravatar.cc/160?img=49" width="72" height="72" alt="Priya Nair">
<div class="tc-stars" aria-label="5 out of 5 stars">★★★★★</div>
<blockquote class="mb-3 tc-quote">“Support replied within minutes and shipped the fix the same day. That is rare and we noticed.”</blockquote>
<figcaption><span class="d-block fw-bold">Priya Nair</span><span class="small wdw-muted">Founder, Kiln Studio</span></figcaption>
</div>
</figure>
<figure class="tc-slide m-0" role="group" aria-roledescription="slide" aria-label="5 of 5">
<div class="wdw-card tc-card text-center p-4 p-md-4">
<img class="tc-avatar" src="https://i.pravatar.cc/160?img=33" width="72" height="72" alt="Daniel Okafor">
<div class="tc-stars" aria-label="5 out of 5 stars">★★★★★</div>
<blockquote class="mb-3 tc-quote">“We rolled it out to three offices in a week. Everyone just understood how it worked.”</blockquote>
<figcaption><span class="d-block fw-bold">Daniel Okafor</span><span class="small wdw-muted">Ops lead, Harbor</span></figcaption>
</div>
</figure>
</div>
</div>
</div>
<div class="d-flex justify-content-center align-items-center gap-3 mt-4">
<button type="button" class="btn btn-outline-secondary rounded-circle tc-btn" id="tc-prev" aria-label="Previous testimonial"><svg width="18" height="18" 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 6-6 6 6 6"/></svg></button>
<div class="d-flex gap-2" id="tc-dots"></div>
<button type="button" class="btn btn-outline-secondary rounded-circle tc-btn" id="tc-next" aria-label="Next testimonial"><svg width="18" height="18" 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 6 6 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 */
.tc-viewport { padding-block: 1.5rem; }
.tc-track { display: flex; gap: 1.25rem; transition: transform .5s cubic-bezier(.22,.8,.3,1); will-change: transform; }
.tc-slide { flex: 0 0 min(88%, 400px); opacity: .45; transform: scale(.9); transition: opacity .4s, transform .4s; }
.tc-slide.is-active { opacity: 1; transform: scale(1); }
.tc-card { height: 100%; padding: 2rem 1.75rem !important; }
.tc-avatar { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; margin-bottom: .75rem; box-shadow: 0 0 0 3px var(--bs-body-bg), 0 0 0 5px var(--bs-primary-border-subtle); }
.tc-stars { color: #f59e0b; letter-spacing: .15em; font-size: .95rem; margin-bottom: .75rem; }
.tc-quote { color: var(--bs-body-color); line-height: 1.6; }
.tc:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 4px; border-radius: 1rem; }
.tc-btn { width: 44px; height: 44px; padding: 0; }
.tc-dot { width: 10px; height: 10px; padding: 0; border: 0; border-radius: 999px; background: var(--bs-border-color); transition: width .25s, background .25s; position: relative; }
.tc-dot::after { content: ""; position: absolute; inset: -17px -4px; }
.tc-dot.is-active { width: 28px; background: var(--bs-primary); }
.tc-dot:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .tc-track, .tc-slide { transition: none; } }
(function () {
function initTestimonialCarousel() {
var root = document.getElementById('tc');
var track = document.getElementById('tc-track');
var prev = document.getElementById('tc-prev');
var next = document.getElementById('tc-next');
var dotsBox = document.getElementById('tc-dots');
if (!root || !track || !prev || !next || !dotsBox) return;
var slides = Array.prototype.slice.call(track.children);
var viewport = root.querySelector('.tc-viewport');
var index = 1;
slides.forEach(function (s, i) {
var d = document.createElement('button');
d.type = 'button'; d.className = 'tc-dot';
d.setAttribute('aria-label', 'Go to testimonial ' + (i + 1));
d.addEventListener('click', function () { go(i); });
dotsBox.appendChild(d);
});
var dots = dotsBox.children;
function layout() {
var s = slides[index];
var offset = viewport.clientWidth / 2 - (s.offsetLeft + s.offsetWidth / 2);
track.style.transform = 'translateX(' + offset + 'px)';
}
function go(i) {
index = Math.max(0, Math.min(slides.length - 1, i));
slides.forEach(function (s, n) {
s.classList.toggle('is-active', n === index);
s.setAttribute('aria-hidden', n === index ? 'false' : 'true');
dots[n].classList.toggle('is-active', n === index);
if (n === index) dots[n].setAttribute('aria-current', 'true'); else dots[n].removeAttribute('aria-current');
});
prev.disabled = index === 0; next.disabled = index === slides.length - 1;
layout();
}
prev.addEventListener('click', function () { go(index - 1); });
next.addEventListener('click', function () { go(index + 1); });
root.addEventListener('keydown', function (e) {
if (e.key === 'ArrowLeft') go(index - 1);
if (e.key === 'ArrowRight') go(index + 1);
});
var startX = null;
root.addEventListener('pointerdown', function (e) { startX = e.clientX; });
root.addEventListener('pointerup', function (e) {
if (startX === null) return;
var dx = e.clientX - startX; startX = null;
if (Math.abs(dx) > 40) go(index + (dx < 0 ? 1 : -1));
});
window.addEventListener('resize', layout);
go(index);
}
initTestimonialCarousel();
})();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.