- No data uploaded
- Instant results
Tailwind CSS Testimonial Slider for Vanilla JS
A production-ready minimal testimonial slider: a customer testimonial carousel that shows one quote at a time with labelled slide buttons — no autoplay, so users stay in control. Pick your brand color, toggle dark mode and corner radius — the live preview and the Vanilla JS code update instantly in your browser.
Live component editor
<!-- Requires Tailwind CSS v3 (CLI/PostCSS build, or the Play CDN for prototypes) -->
<section class="px-6 py-16" aria-roledescription="carousel" aria-label="Customer testimonials">
<div class="max-w-2xl mx-auto text-center">
<span class="inline-flex items-center px-2.5 py-0.5 text-xs font-semibold rounded-full bg-[#4f46e5]/10 text-[#4f46e5]">Loved by teams</span>
<div class="mt-6 p-8 bg-white border border-slate-200 shadow-sm rounded-xl">
<figure data-when="slide:1">
<blockquote class="text-xl font-medium leading-relaxed text-slate-900">“We shipped our new checkout in a single afternoon. Conversion went up 18% the same week.”</blockquote>
<figcaption class="mt-6 text-sm text-slate-500"><strong>Priya Sharma</strong> · Head of Growth, Kartly</figcaption>
</figure>
<figure data-when="slide:2" hidden>
<blockquote class="text-xl font-medium leading-relaxed text-slate-900">“The components are clean, accessible and they just work with our design tokens.”</blockquote>
<figcaption class="mt-6 text-sm text-slate-500"><strong>Daniel Okafor</strong> · Staff Engineer, Lumen</figcaption>
</figure>
<figure data-when="slide:3" hidden>
<blockquote class="text-xl font-medium leading-relaxed text-slate-900">“Dark mode and theming out of the box saved us weeks of design back-and-forth.”</blockquote>
<figcaption class="mt-6 text-sm text-slate-500"><strong>Mia Fischer</strong> · Product Designer, Northwind</figcaption>
</figure>
</div>
<div class="mt-6 flex justify-center gap-2" role="group" aria-label="Choose testimonial">
<button type="button" class="inline-flex items-center justify-center px-3 py-2 text-sm font-semibold rounded-lg border transition-colors border-slate-300 text-slate-700 hover:bg-slate-50 aria-pressed:border-[#4f46e5] aria-pressed:text-[#4f46e5] aria-pressed:ring-1 aria-pressed:ring-[#4f46e5]" data-set="slide:1" data-pressed="slide:1" aria-pressed="true" aria-label="Show testimonial 1">1</button>
<button type="button" class="inline-flex items-center justify-center px-3 py-2 text-sm font-semibold rounded-lg border transition-colors border-slate-300 text-slate-700 hover:bg-slate-50 aria-pressed:border-[#4f46e5] aria-pressed:text-[#4f46e5] aria-pressed:ring-1 aria-pressed:ring-[#4f46e5]" data-set="slide:2" data-pressed="slide:2" aria-pressed="false" aria-label="Show testimonial 2">2</button>
<button type="button" class="inline-flex items-center justify-center px-3 py-2 text-sm font-semibold rounded-lg border transition-colors border-slate-300 text-slate-700 hover:bg-slate-50 aria-pressed:border-[#4f46e5] aria-pressed:text-[#4f46e5] aria-pressed:ring-1 aria-pressed:ring-[#4f46e5]" data-set="slide:3" data-pressed="slide:3" aria-pressed="false" aria-label="Show testimonial 3">3</button>
</div>
</div>
</section>
<script>
(() => {
const state = { slide: "1" };
const actions = { };
const pair = (s) => s.split(':');
const sync = () => {
document.querySelectorAll('[data-show]').forEach((el) => (el.hidden = !state[el.dataset.show]));
document.querySelectorAll('[data-hide]').forEach((el) => (el.hidden = !!state[el.dataset.hide]));
document.querySelectorAll('[data-when]').forEach((el) => { const [k, v] = pair(el.dataset.when); el.hidden = state[k] !== v; });
document.querySelectorAll('[data-pressed]').forEach((el) => { const [k, v] = pair(el.dataset.pressed); el.setAttribute('aria-pressed', String(state[k] === v)); });
document.querySelectorAll('[data-expanded]').forEach((el) => el.setAttribute('aria-expanded', String(!!state[el.dataset.expanded])));
};
document.addEventListener('click', (e) => {
const t = e.target.closest('[data-toggle],[data-open],[data-close],[data-set],[data-call]');
if (!t) return;
const { toggle, open, close, set, call } = t.dataset;
if (call) actions[call]?.(e);
if (toggle) state[toggle] = !state[toggle];
if (open) state[open] = true;
if (close) state[close] = false;
if (set) { const [k, v] = pair(set); state[k] = v; }
sync();
});
sync();
})();
</script>
More Tailwind components for Vanilla JS
All components →- Hero Section A landing-page hero with an announcement badge, a large headline, supporting copy, primary and secondary calls to action and a row of social-proof stats
- Feature Grid A marketing section with a centered heading and a responsive grid of six feature cards, each with an icon badge, title and description
- Pricing Table A three-tier pricing section with a monthly/yearly billing toggle, a highlighted “most popular” plan and feature checklists
- Currency Pricing Table A dynamic pricing section that detects the visitor’s currency, shows purchasing-power-adjusted regional prices and lets users switch between USD, EUR, GBP, INR and JPY
- FAQ Accordion A frequently-asked-questions section with four expandable items, each toggled by a button that exposes its state via aria-expanded
- Login Modal A centered sign-in dialog with email and password fields, “remember me”, a forgot-password link and a social sign-in button
- Signup Form A registration card with name, email and password fields, a password hint, a terms-of-service checkbox and a primary call to action
- Navbar A responsive top navigation bar with a logo, primary links, a sign-in/CTA pair on desktop and a collapsible hamburger menu on mobile
Install Tailwind CSS for Vanilla JS
Prototype instantly with the Play CDN, or install the Tailwind CLI for production:
<script src="https://cdn.tailwindcss.com"></script>npm install -D tailwindcss@3
npx tailwindcss init
npx tailwindcss -i ./src/input.css -o ./dist/output.css --watchAdd ./**/*.html to content in tailwind.config.js and put the three @tailwind directives in src/input.css.
Use the testimonial slider in Vanilla JS
Paste the markup where the component should appear. The small inline <script> wires up the interactive state with one delegated click listener — no framework needed.
Accessibility & customization
There is no auto-rotation (WCAG 2.2.2), each slide button has an aria-label and aria-pressed state, and quotes are marked up with <blockquote> and <figcaption>.
Every color, radius and dark-mode choice is baked into plain utility classes, so the copied code has no runtime dependency on this site.
Compatibility
| Item | Details |
|---|---|
| CSS framework | Tailwind CSS v3.4+ |
| Library | Plain HTML + optional vanilla JS |
| Interactive state | slide |
| Dark mode | Yes — toggle in the editor |
| Style | Minimal |