Quote slider with portraits
One big testimonial at a time: the portrait stack shuffles, the quote reveals line by line, and a progress ring counts down to the next.
"use client";
import { useEffect, useRef, useState, type CSSProperties } from "react";
import "./testimonial-slider.css";
type Slide = {
quote: string;
name: string;
role: string;
photo: string;
tone: string;
};
const SLIDES: Slide[] = [
{
quote:
"They rebuilt our checkout in three weeks. Conversion went up 18% and support tickets about payments basically stopped.",
name: "Nadia Petrova",
role: "Head of E-commerce, Halden Outdoor",
photo: "/images/templates-testimonial-slider-portrait-01.jpg",
tone: "#ff5a1f",
},
{
quote:
"Every handoff came with notes our engineers could actually use. It felt like the studio was part of our team.",
name: "Kwame Mensah",
role: "VP Engineering, Tidepool",
photo: "/images/templates-testimonial-slider-portrait-02.jpg",
tone: "#2b35ff",
},
{
quote:
"The new brand made our tiny bakery look like it belongs on a shelf in Tokyo. Wholesale orders doubled.",
name: "Mei Tanaka",
role: "Owner, Crumb & Co",
photo: "/images/templates-testimonial-slider-portrait-03.jpg",
tone: "#d7ff3a",
},
];
const DURATION = 7000;
/** A portrait that falls back to a toned block with initials until the photo exists. */
function Portrait({ s }: { s: Slide }) {
const img = useRef<HTMLImageElement>(null);
const [missing, setMissing] = useState(false);
useEffect(() => {
const el = img.current;
if (el && el.complete && el.naturalWidth === 0) setMissing(true);
}, []);
return (
<div className="gu-qs__photo" style={{ "--tone": s.tone } as CSSProperties}>
<span aria-hidden="true">
{s.name
.split(" ")
.map((p) => p[0])
.join("")}
</span>
{!missing && (
<img ref={img} src={s.photo} alt="" onError={() => setMissing(true)} />
)}
</div>
);
}
/**
* TestimonialSlider
* - Autoplays every 7s with a progress ring; stops for good after any interaction.
* - Portraits sit in a fanned stack; the active one comes to the front.
* - Pointer swipe (> 50px) and arrow keys change slides.
*/
export function TestimonialSlider({
theme = "light",
}: {
theme?: "light" | "dark";
}) {
const [i, setI] = useState(0);
const [auto, setAuto] = useState(true);
const startX = useRef<number | null>(null);
const n = SLIDES.length;
useEffect(() => {
if (!auto || matchMedia("(prefers-reduced-motion: reduce)").matches) return;
const t = setTimeout(() => setI((x) => (x + 1) % n), DURATION);
return () => clearTimeout(t);
}, [i, auto, n]);
const go = (to: number) => {
setAuto(false);
setI((to + n) % n);
};
const s = SLIDES[i];
return (
<section
className="gu-qs"
data-theme={theme}
aria-roledescription="carousel"
aria-label="What clients say"
onKeyDown={(e) => {
if (e.key === "ArrowRight") go(i + 1);
if (e.key === "ArrowLeft") go(i - 1);
}}
>
<div className="gu-qs__stack" aria-hidden="true">
{SLIDES.map((sl, k) => {
const pos = (k - i + n) % n; // 0 = front
return (
<div
key={sl.name}
className="gu-qs__card"
style={{ "--pos": pos } as CSSProperties}
data-front={pos === 0 ? "" : undefined}
>
<Portrait s={sl} />
</div>
);
})}
</div>
<div
className="gu-qs__body"
onPointerDown={(e) => (startX.current = e.clientX)}
onPointerUp={(e) => {
if (startX.current === null) return;
const dx = e.clientX - startX.current;
if (Math.abs(dx) > 50) go(i + (dx < 0 ? 1 : -1));
startX.current = null;
}}
>
<figure
key={i}
className="gu-qs__fig"
role="group"
aria-roledescription="slide"
aria-label={`${i + 1} of ${n}`}
>
<blockquote>
{s.quote.split(/(?<=[.,]) /).map((part, k) => (
<span key={k} style={{ "--k": k } as CSSProperties}>
{part}{" "}
</span>
))}
</blockquote>
<figcaption>
<b>{s.name}</b>
<small>{s.role}</small>
</figcaption>
</figure>
<div className="gu-qs__nav">
<button
type="button"
onClick={() => go(i - 1)}
aria-label="Previous testimonial"
>
<svg viewBox="0 0 20 20" aria-hidden="true">
<path d="M12.5 4 6.5 10l6 6" />
</svg>
</button>
<span
className="gu-qs__ring"
data-auto={auto ? "" : undefined}
key={`r${i}${auto}`}
style={{ "--dur": `${DURATION}ms` } as CSSProperties}
>
<svg viewBox="0 0 36 36" aria-hidden="true">
<circle cx="18" cy="18" r="16" />
<circle cx="18" cy="18" r="16" className="gu-qs__ring-fill" />
</svg>
<span>
{i + 1}/{n}
</span>
</span>
<button
type="button"
onClick={() => go(i + 1)}
aria-label="Next testimonial"
>
<svg viewBox="0 0 20 20" aria-hidden="true">
<path d="m7.5 4 6 6-6 6" />
</svg>
</button>
</div>
</div>
<p className="gu-sr" aria-live="polite">
{auto ? "" : `Testimonial ${i + 1} of ${n}: ${s.name}`}
</p>
</section>
);
}
Paste this into ChatGPT, Claude, Cursor, v0, Lovable or Bolt. It describes the layout, motion, colors and accessibility and includes the code, so the AI can rebuild it in any framework.
# Build this UI piece: Quote slider with portraits
You are a senior front-end engineer. Recreate the piece below in my project. If I don't say which framework I use, ask once, then build it in that framework (React, Vue, Svelte, Angular, Astro, plain HTML/CSS/JS or anything else). Keep the behavior, motion, colors, spacing and accessibility exactly as described. Keep the code clean and commented for beginners.
## What it is
A testimonial carousel for an agency site: a fanned stack of portrait cards on the left and one big quote on the right. The active portrait comes to the front, the quote fades in phrase by phrase from a blur, and a progress ring around "1/3" counts down to the next slide.
## Layout and look
- Card 900px max, radius 32px, background #fbf8f2 (dark #18181b). Two columns (portraits 0.8fr, quote 1.4fr); stacks under 620px.
- Portrait stack: 4:5 cards, radius 24px, deep soft shadow. Card behind = shifted right 9%, rotated 5°, scaled 93%, darker; the next one more so.
- Quote: clamp 21–32px, weight 800, tracking -0.03em; name bold, role muted.
- Nav: two 48px round outline buttons (fill Ink on hover) and a 48px ring with an orange stroke filling over 7s.
## Behavior and motion
1. Autoplay every 7s; any click, key or swipe stops autoplay for good.
2. Stack transforms transition over 800ms cubic-bezier(0.16, 1, 0.3, 1).
3. Quote is split at commas/periods; each part fades from blur 6px with a 120ms stagger.
4. Swipe > 50px changes slides; ArrowLeft/Right too.
## Images
Three portraits (4:5). Until the files exist, each card shows the person's initials on a striped brand-color block.
## Accessibility
- Section with aria-roledescription="carousel"; each slide is a group "n of 3". Portraits are decorative. A polite live region announces manual changes.
- prefers-reduced-motion: no autoplay, a simple fade.
## Props
theme. Edit SLIDES and DURATION.
## Reference implementation
The original is written in React with one plain CSS file. Dependencies: none (plain React and CSS). Translate it faithfully; do not add new libraries unless my framework needs them.
### TestimonialSlider.tsx
```tsx
"use client";
import { useEffect, useRef, useState, type CSSProperties } from "react";
import "./testimonial-slider.css";
type Slide = {
quote: string;
name: string;
role: string;
photo: string;
tone: string;
};
const SLIDES: Slide[] = [
{
quote:
"They rebuilt our checkout in three weeks. Conversion went up 18% and support tickets about payments basically stopped.",
name: "Nadia Petrova",
role: "Head of E-commerce, Halden Outdoor",
photo: "/images/templates-testimonial-slider-portrait-01.jpg",
tone: "#ff5a1f",
},
{
quote:
"Every handoff came with notes our engineers could actually use. It felt like the studio was part of our team.",
name: "Kwame Mensah",
role: "VP Engineering, Tidepool",
photo: "/images/templates-testimonial-slider-portrait-02.jpg",
tone: "#2b35ff",
},
{
quote:
"The new brand made our tiny bakery look like it belongs on a shelf in Tokyo. Wholesale orders doubled.",
name: "Mei Tanaka",
role: "Owner, Crumb & Co",
photo: "/images/templates-testimonial-slider-portrait-03.jpg",
tone: "#d7ff3a",
},
];
const DURATION = 7000;
/** A portrait that falls back to a toned block with initials until the photo exists. */
function Portrait({ s }: { s: Slide }) {
const img = useRef<HTMLImageElement>(null);
const [missing, setMissing] = useState(false);
useEffect(() => {
const el = img.current;
if (el && el.complete && el.naturalWidth === 0) setMissing(true);
}, []);
return (
<div className="gu-qs__photo" style={{ "--tone": s.tone } as CSSProperties}>
<span aria-hidden="true">
{s.name
.split(" ")
.map((p) => p[0])
.join("")}
</span>
{!missing && (
<img ref={img} src={s.photo} alt="" onError={() => setMissing(true)} />
)}
</div>
);
}
/**
* TestimonialSlider
* - Autoplays every 7s with a progress ring; stops for good after any interaction.
* - Portraits sit in a fanned stack; the active one comes to the front.
* - Pointer swipe (> 50px) and arrow keys change slides.
*/
export function TestimonialSlider({
theme = "light",
}: {
theme?: "light" | "dark";
}) {
const [i, setI] = useState(0);
const [auto, setAuto] = useState(true);
const startX = useRef<number | null>(null);
const n = SLIDES.length;
useEffect(() => {
if (!auto || matchMedia("(prefers-reduced-motion: reduce)").matches) return;
const t = setTimeout(() => setI((x) => (x + 1) % n), DURATION);
return () => clearTimeout(t);
}, [i, auto, n]);
const go = (to: number) => {
setAuto(false);
setI((to + n) % n);
};
const s = SLIDES[i];
return (
<section
className="gu-qs"
data-theme={theme}
aria-roledescription="carousel"
aria-label="What clients say"
onKeyDown={(e) => {
if (e.key === "ArrowRight") go(i + 1);
if (e.key === "ArrowLeft") go(i - 1);
}}
>
<div className="gu-qs__stack" aria-hidden="true">
{SLIDES.map((sl, k) => {
const pos = (k - i + n) % n; // 0 = front
return (
<div
key={sl.name}
className="gu-qs__card"
style={{ "--pos": pos } as CSSProperties}
data-front={pos === 0 ? "" : undefined}
>
<Portrait s={sl} />
</div>
);
})}
</div>
<div
className="gu-qs__body"
onPointerDown={(e) => (startX.current = e.clientX)}
onPointerUp={(e) => {
if (startX.current === null) return;
const dx = e.clientX - startX.current;
if (Math.abs(dx) > 50) go(i + (dx < 0 ? 1 : -1));
startX.current = null;
}}
>
<figure
key={i}
className="gu-qs__fig"
role="group"
aria-roledescription="slide"
aria-label={`${i + 1} of ${n}`}
>
<blockquote>
{s.quote.split(/(?<=[.,]) /).map((part, k) => (
<span key={k} style={{ "--k": k } as CSSProperties}>
{part}{" "}
</span>
))}
</blockquote>
<figcaption>
<b>{s.name}</b>
<small>{s.role}</small>
</figcaption>
</figure>
<div className="gu-qs__nav">
<button
type="button"
onClick={() => go(i - 1)}
aria-label="Previous testimonial"
>
<svg viewBox="0 0 20 20" aria-hidden="true">
<path d="M12.5 4 6.5 10l6 6" />
</svg>
</button>
<span
className="gu-qs__ring"
data-auto={auto ? "" : undefined}
key={`r${i}${auto}`}
style={{ "--dur": `${DURATION}ms` } as CSSProperties}
>
<svg viewBox="0 0 36 36" aria-hidden="true">
<circle cx="18" cy="18" r="16" />
<circle cx="18" cy="18" r="16" className="gu-qs__ring-fill" />
</svg>
<span>
{i + 1}/{n}
</span>
</span>
<button
type="button"
onClick={() => go(i + 1)}
aria-label="Next testimonial"
>
<svg viewBox="0 0 20 20" aria-hidden="true">
<path d="m7.5 4 6 6-6 6" />
</svg>
</button>
</div>
</div>
<p className="gu-sr" aria-live="polite">
{auto ? "" : `Testimonial ${i + 1} of ${n}: ${s.name}`}
</p>
</section>
);
}
```
### testimonial-slider.css
```css
/* TestimonialSlider: change these colors to match your brand. */
.gu-qs {
--bg: #fbf8f2;
--text: #0e0e10;
--muted: #57534b;
--line: rgb(14 14 16 / 0.14);
--accent: #ff5a1f;
--focus: #2b35ff;
--ease: cubic-bezier(0.16, 1, 0.3, 1);
container-type: inline-size;
display: grid;
grid-template-columns: minmax(180px, 0.8fr) 1.4fr;
align-items: center;
gap: clamp(28px, 6%, 64px);
width: min(100%, 900px);
padding: clamp(24px, 5%, 48px);
border-radius: 32px;
background: var(--bg);
color: var(--text);
font-family: system-ui, sans-serif;
}
.gu-qs[data-theme="dark"] {
--bg: #18181b;
--text: #f3eee3;
--muted: #aea89c;
--line: rgb(243 238 227 / 0.14);
--focus: #d7ff3a;
}
.gu-qs__stack {
position: relative;
aspect-ratio: 4 / 5;
margin: 0 12% 0 4%;
}
.gu-qs__card {
position: absolute;
inset: 0;
z-index: calc(10 - var(--pos));
overflow: hidden;
border-radius: 24px;
box-shadow: 0 20px 40px -20px rgb(0 0 0 / 0.45);
transform: translateX(calc(var(--pos) * 9%)) rotate(calc(var(--pos) * 5deg))
scale(calc(1 - var(--pos) * 0.07));
filter: brightness(calc(1 - var(--pos) * 0.12));
transition:
transform 0.8s var(--ease),
filter 0.8s;
}
.gu-qs__photo {
position: absolute;
inset: 0;
display: grid;
place-items: center;
background: var(--tone)
repeating-linear-gradient(
135deg,
rgb(255 255 255 / 0.15) 0 2px,
transparent 2px 16px
);
}
.gu-qs__photo > span {
color: rgb(14 14 16 / 0.55);
font-size: clamp(2.5rem, 9cqi, 4.5rem);
font-weight: 900;
letter-spacing: -0.05em;
}
.gu-qs__photo img {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
.gu-qs__body {
display: grid;
gap: 28px;
touch-action: pan-y;
user-select: none;
}
.gu-qs__fig {
margin: 0;
}
.gu-qs blockquote {
margin: 0 0 22px;
font-size: clamp(1.3rem, 3.6cqi, 2rem);
font-weight: 800;
letter-spacing: -0.03em;
line-height: 1.18;
text-wrap: pretty;
}
.gu-qs blockquote span {
display: inline;
animation: gu-qs-line 0.8s calc(var(--k) * 120ms) var(--ease) both;
}
@keyframes gu-qs-line {
from {
opacity: 0;
filter: blur(6px);
}
}
.gu-qs figcaption {
display: grid;
animation: gu-qs-line 0.6s 0.35s var(--ease) both;
}
.gu-qs figcaption small {
color: var(--muted);
}
.gu-qs__nav {
display: flex;
align-items: center;
gap: 10px;
}
.gu-qs__nav button {
display: grid;
place-items: center;
width: 48px;
height: 48px;
border: 1.5px solid var(--line);
border-radius: 50%;
background: none;
color: inherit;
cursor: pointer;
transition:
background-color 0.2s,
color 0.2s,
border-color 0.2s;
}
.gu-qs__nav button:hover {
border-color: var(--text);
background: var(--text);
color: var(--bg);
}
.gu-qs__nav button:focus-visible {
outline: 3px solid var(--focus);
outline-offset: 2px;
}
.gu-qs__nav svg {
width: 18px;
fill: none;
stroke: currentColor;
stroke-width: 2.2;
stroke-linecap: round;
stroke-linejoin: round;
}
.gu-qs__ring {
position: relative;
display: grid;
place-items: center;
width: 48px;
height: 48px;
font-size: 0.72rem;
font-weight: 800;
font-variant-numeric: tabular-nums;
}
.gu-qs__ring svg {
position: absolute;
inset: 0;
rotate: -90deg;
fill: none;
stroke: var(--line);
stroke-width: 2.5;
}
.gu-qs__ring-fill {
stroke: var(--accent);
stroke-dasharray: 101;
stroke-dashoffset: 101;
}
.gu-qs__ring[data-auto] .gu-qs__ring-fill {
animation: gu-qs-ring var(--dur) linear forwards;
}
@keyframes gu-qs-ring {
to {
stroke-dashoffset: 0;
}
}
.gu-sr {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
}
@container (max-width: 620px) {
/* The root is the container, so it cannot query itself: its children span the full row instead */
.gu-qs > * {
grid-column: 1 / -1;
}
.gu-qs__stack {
width: 52%;
margin: 0 auto 0 0;
}
}
@media (prefers-reduced-motion: reduce) {
.gu-qs__card {
transition: none;
}
.gu-qs blockquote span,
.gu-qs figcaption {
animation: gu-qs-fade 0.2s both;
}
@keyframes gu-qs-fade {
from {
opacity: 0;
}
}
.gu-qs__ring-fill {
display: none;
}
}
```
You might also want
Next piece: Radial action menuTestimonial wall
Templates, beginner
Usage pricing calculator
Templates, intermediate
404 page section
Templates, intermediate


