Capsule Testimonials
Reviews sit as slim capsules with a face and a name, then open into a full card on click. Use it on a landing or pricing page with 4 to 7 reviews.
People said nice things. We kept them.
Real words from people who shipped with us. Open a capsule to read one.
I dropped in one section and the whole landing page finally felt finished. My developer asked which agency we hired.
Amara OkaforProduct Designer, Lumen HealthRated 5 out of 5
npx shadcn@latest add https://impeccableui.vercel.app/r/capsule-testimonials.jsonRun it in a project set up with shadcn. No other packages needed. Or open and copy the file into components/ui/capsule-testimonials.tsx.
Prompts
Paste one into Claude Code, Cursor or any AI coding tool. Install adds this exact section and asks only which page it goes on. Blend asks four short questions (where, your reviews, your card colors and your heading), then fits it to your product without changing the design.
# Capsule Testimonials
A 1-file React section from Impeccable. Add it to this project so it works and looks exactly like the source below, in the one place I choose, and change nothing else.
A testimonial section where every review waits as a slim, rounded capsule: the person's photo at the bottom and their name written up the side. Hovering a capsule makes it a little taller and wider and stretches the round photo into a tall portrait. Clicking it opens it smoothly into a wide card while the card that was open eases back into a capsule at the same pace, so nothing snaps. As a card opens, its top part (quote mark, words, date) settles from 60% opacity and 90% size to full, and the rating stars pop in one after another.
## Before you build: one question
Look through this project first: its pages and their sections (is there a landing, pricing or about page with a spot for reviews?), any reviews or quotes it already shows (names, roles, photos, ratings) and where they live. Then ask me this in one message and wait for my answer:
- **Which page should it go on, and between which sections?** Suggest the 1–3 best places from my pages (it works best after the features or pricing on a landing page, where people want proof).
*Why: reviews persuade most right after people have seen what they would buy.*
Ask nothing else. If I say *skip*, use the best suggestion. The section needs reviews to show: use my real reviews and photos if you found them, otherwise keep its made-up samples and tell me they need replacing.
## Keep it as it is
The section is the design: slim round capsules with the photo at the bottom and the name written up the side, the hover that grows the capsule and stretches the photo into a portrait, the smooth open where the old card eases back into a capsule at the same pace, the words settling from 60% opacity and 90% size, the rounder 28px corners on the open card, and the stars popping in one by one. Keep them exactly as in the source. If something doesn't fit my project, tell me instead of changing it.
- Add only the section file and the one place I picked. Don't add packages, change other files, or restyle anything.
- Don't add the demo parts from the Impeccable website: the preview card, the preview size buttons and fullscreen, the hint text, the drawn sample faces, and the self-playing TV on the home page.
## Fastest path
If this project has a `components.json` (shadcn), run `npx shadcn@latest add https://impeccableui.vercel.app/r/capsule-testimonials.json`.
If the command succeeds, only fix import paths to match this project and skip ahead. If it fails or there is no `components.json`, build it by hand as below.
## Build it
- Stack: React 18 or 19 with TypeScript. No other packages: the motion is CSS transitions, and the script only measures the row and remembers which review is open.
- JavaScript project? Name the file `capsule-testimonials.jsx` and remove the type annotations; nothing else changes.
- Create this file, in this project's usual place for components:
- `components/ui/capsule-testimonials.tsx`
- Keep these exports and their names: `CapsuleTestimonials`, `CapsuleTestimonialsProps`, `CapsuleTestimonial`, `CAPSULE_TESTIMONIALS`.
- Keep `"use client"` at the top in Next.js App Router projects. In other setups it is harmless. A page that renders it can stay a server component.
- Keep the CSS block and the tuning values at the top (`CAP`, `CAP_HOVER`, `GAP`, `ROW_H`, `OPEN_H`, `OPEN_MS`, `EASE`, `TEXT_FROM`, `STAR_STEP`, `STAR_DELAY`, `PALETTE`) exactly as written. They are the design: capsules are 56px wide and grow to 64px under the pointer, 8px apart, in a 400px tall row; a capsule sits 22px shorter than the open card at the top and bottom (8px on hover); opening takes 720ms on `cubic-bezier(.32,.72,0,1)` for both the card that opens and the one that closes; the top part of the card settles from 60% opacity and 90% size; the stars start 380ms after opening, 90ms apart, with a small overshoot.
- Keep the corners: capsules are fully round (half their width), the photo inside keeps a 6px ring of the capsule color (its radius is the capsule's minus 6px), and the open card's corners are 3.5 times `--radius-lg` (28px with an 8px theme radius), rounder than a usual card.
- Keep the colors as written: the page text reads `--foreground` and `--background` (or `--fg` and `--bg`), and each card has its own color from `PALETTE` (six soft colors that read on a light page and a dark one) unless a review sets `color` and `ink`.
- Keep the speed and layout rules: the open card's content is laid out at the full open size (measured by the script), so its words never re-wrap while the card grows; only one card is open at a time; photos keep `loading="lazy"` and `decoding="async"` and can't be selected or dragged.
- Keep the fallbacks: hover effects only on devices with a real pointer (`@media (hover: hover)`); under 560px of section width the capsules lie down and stack with the open card growing downward; with `prefers-reduced-motion: reduce` the cards swap at once and the words and stars only fade in; a missing or broken photo shows the person's initials; the arrow keys, Home and End move between reviews, and keyboard users land on the card they opened; closed cards are hidden from screen readers and the stars read as "Rated 5 out of 5".
## Use it
```tsx
// app/page.tsx (the page I picked)
import { CapsuleTestimonials } from "@/components/ui/capsule-testimonials";
const REVIEWS = [
{ name: "Lena Fischer", role: "COO, Northwind", quote: "We moved our whole team over in a week.", date: "Oct 2026", rating: 5, photo: "/people/lena.jpg" },
{ name: "Omar Haddad", role: "Founder, Globex", quote: "Support answers before I finish typing.", date: "Sep 2026", rating: 5, photo: "/people/omar.jpg" },
{ name: "Mia Chen", role: "Designer, Initech", quote: "It finally looks like our brand.", date: "Aug 2026", rating: 4, photo: "/people/mia.jpg" },
];
export default function Home() {
return (
<main>
{/* ...my existing sections... */}
<CapsuleTestimonials title="What our customers say" description="Open a capsule to read one." items={REVIEWS} />
{/* ...the next section... */}
</main>
);
}
```
- Put it between the two sections I picked, full width. It centres its own 896px column with 24px sides (16px on phones), so don't wrap it in extra padding.
- `items` takes `{ name, role, quote, date, rating, photo, alt, color, ink }`; 4 to 7 reviews read best. Portrait photos work best: the capsule shows the face, the hover shows more. A review without a photo shows initials.
- The default reviews and the default heading are made-up samples. If you found no real reviews, keep them but tell me clearly, so nothing fake ships on my page.
## How the section works
Read this before you touch anything, so you know what the code does and why it must stay as it is.
1. **One row, one open card.** Every review is a flex item in one row. A closed review keeps its 56px capsule width; the open one takes all the space left over (`flex-grow: 1`). When you open another, the old one's grow eases from 1 to 0 and the new one's from 0 to 1 over the same 720ms on the same curve, so one closes exactly as fast as the other opens and the row's width never changes. That is why nothing snaps.
2. **The shape.** Inside each item a colored shape sits 22px in from the top and bottom, fully round. When it opens, it reaches the full height and its corners settle to 28px, on the same curve.
3. **The capsule face.** A button fills the capsule: the name written upward (vertical text, turned to read bottom to top) and the round photo at the bottom with a 6px ring. On hover (pointer devices only) the capsule grows to 64px wide and 8px from the top and bottom, and the photo stretches from a circle into a tall portrait, from soft color to full color. It fades out as the capsule opens and back in once it has closed.
4. **The open card.** Its content is laid out at the full open width (the row width minus the other capsules), so the words never re-wrap as the card grows; the card simply uncovers them. The top part (quote mark, words, date) starts at 60% opacity and 90% size from its top left corner and settles to 100% and 100%. The name, role, photo and stars come in just after.
5. **The stars.** Five stars, the earned ones solid and the rest faint. They pop in one after another (90ms apart) with a little overshoot. The first card plays this when the section first scrolls into view.
6. **Narrow screens.** Under 560px of section width (a container query, so it follows the section's own width), the row turns into a column: capsules lie down as 56px tall pills with the photo on the left and the name beside it, and the open card grows downward.
7. **Keyboard.** Each capsule is a button. Enter or Space opens it and moves focus to the card. The arrow keys, Home and End open the next, previous, first or last review.
## Check
- It type-checks and the page renders with no console errors.
- The first review is open and its words settle in and its stars pop in one by one when the section scrolls into view. Hovering another capsule makes it taller and wider and stretches its photo into a portrait. Clicking it opens it over 0.72s while the open card eases back into a capsule, with no jump in the row's width. The words never re-wrap while a card grows. Only one card is open at a time.
- It looks right in light and dark mode (check both): page text in my text colors, each card's words readable on its own color.
- It works with a finger on a phone at 375px wide: the capsules lie down and stack, a tap opens one, and nothing scrolls sideways.
- With `prefers-reduced-motion: reduce`, cards swap at once and the words and stars only fade in.
- Nothing else on the site looks or behaves differently.
- Finish with a short report: the files you added or changed, where it's placed, and every place where you had to do something differently from the source, and why.
## Source
The reference implementation. Copy it as-is, then apply only the changes listed above.
### `components/ui/capsule-testimonials.tsx`
```tsx
"use client";
/**
* Capsule Testimonials, from Impeccable.
*
* A testimonial section where every review starts as a slim capsule: the
* person's photo at the bottom and their name written up the side. One review
* is open at a time as a wide card.
*
* - Hover a capsule: it grows a little taller and wider, and its round photo
* stretches into a tall portrait, so you see more of the person.
* - Click (or tap) a capsule: it opens smoothly while the open card eases
* back into a capsule at the same pace, so the row never snaps.
* - As a card opens, its top part (quote mark, words, date) settles from 60%
* opacity and 90% size to full, and the rating stars pop in one by one.
* - Arrow keys move between reviews. Under 560px wide, the capsules lie
* down and stack, and the open card grows downward instead.
*
* No packages. Page colors come from the page's own theme variables
* (--foreground / --background, else --fg / --bg). Each review has its own
* card color, with a default palette that reads well in light and dark mode.
*/
import { useCallback, useEffect, useId, useRef, useState, type CSSProperties, type KeyboardEvent, type ReactNode } from "react";
export type CapsuleTestimonial = {
/** Full name. Written up the capsule and under the review. */
name: string;
/** Their role or company, like "Head of Product, Lumen". */
role?: ReactNode;
/** What they said. One to three sentences reads best. */
quote: ReactNode;
/** When they said it, like "Oct 2026". Shown at the top right of the open card. */
date?: ReactNode;
/** Stars out of 5 (0 to 5, whole numbers). Leave it out to hide the stars. */
rating?: number;
/** Their photo. A portrait works best: the capsule shows the face, the hover shows more. */
photo?: string;
/** Alt text for the photo. Defaults to the name. */
alt?: string;
/** The card color: any CSS color or variable, like "var(--primary)". Defaults to the built-in palette. */
color?: string;
/** The text color on that card: "light" or "dark". Set it when you set a custom color. */
ink?: "light" | "dark";
};
export type CapsuleTestimonialsProps = {
/** The reviews, left to right. 3 to 7 reads best. */
items?: CapsuleTestimonial[];
/** The heading above the row. Pass null to hide it. */
title?: ReactNode;
/** The line under the heading. Pass null to hide it. */
description?: ReactNode;
/** Which review starts open (0 is the first). */
defaultOpen?: number;
/** Control which review is open yourself (for example to cycle them). Pair it with onOpenChange. */
open?: number;
/** Called with the index of the review that opens. */
onOpenChange?: (index: number) => void;
className?: string;
style?: CSSProperties;
};
/* ---------- the design: keep as written ---------- */
const CAP = 56; // capsule width (or height when the capsules lie down)
const CAP_HOVER = 64; // a capsule under the pointer grows to this
const GAP = 8; // space between capsules
const ROW_H = 400; // height of the row on a wide section
const OPEN_H = 320; // height of the open card when the capsules stack (under 560px)
const OPEN_MS = 720; // the open card grows while the old one shrinks, on the same curve
const EASE = "cubic-bezier(.32,.72,0,1)"; // quick to start, long soft landing: nothing snaps
const TEXT_FROM = { opacity: 0.6, scale: 0.9 }; // the quote, words and date settle from here to 100%
const STAR_STEP = 90; // ms between stars as they pop in
const STAR_DELAY = 380; // ms after opening before the first star
const clampIndex = (n: unknown, len: number) =>
typeof n === "number" && Number.isFinite(n) ? Math.min(len - 1, Math.max(0, Math.round(n))) : 0;
/** The built-in card colors: [color, ink]. They read well on a light page and on a dark one. */
const PALETTE: [string, "light" | "dark"][] = [
["oklch(0.47 0.2 282)", "light"], // violet
["oklch(0.93 0.025 85)", "dark"], // oat
["oklch(0.36 0.05 175)", "light"], // pine
["oklch(0.85 0.09 62)", "dark"], // apricot
["oklch(0.38 0.07 262)", "light"], // ink blue
["oklch(0.83 0.07 330)", "dark"], // orchid
];
const CSS = `
.ict {
--ict-fg: var(--foreground, var(--fg, CanvasText));
--ict-bg: var(--background, var(--bg, Canvas));
--ict-muted: color-mix(in oklab, var(--ict-fg) 62%, var(--ict-bg));
--ict-cap: ${CAP}px;
--ict-gap: ${GAP}px;
--ict-r: calc(var(--radius-lg, 8px) * 3.5); /* the open card: soft, calm corners (28px with an 8px theme radius) */
--ict-ease: ${EASE};
--ict-ms: ${OPEN_MS}ms;
container-type: inline-size;
position: relative; box-sizing: border-box; width: 100%;
color: var(--ict-fg); font-family: inherit; -webkit-font-smoothing: antialiased;
}
.ict *, .ict *::before, .ict *::after { box-sizing: border-box; }
.ict-in { max-width: 56rem; margin: 0 auto; padding: 96px 24px; }
.ict-head { text-align: center; margin-bottom: 48px; }
.ict-title { margin: 0; font-size: 40px; line-height: 1.1; font-weight: 600; letter-spacing: -.035em; text-wrap: balance; overflow-wrap: anywhere; }
.ict-desc { margin: 14px auto 0; max-width: 460px; font-size: 17px; line-height: 1.55; color: var(--ict-muted); text-wrap: pretty; overflow-wrap: anywhere; }
/* The row: every review is a flex item. Closed ones keep their capsule width;
the open one takes all the room left (flex-grow 1). Both grow values ease on
the same curve at the same time, so one opens exactly as fast as the other closes. */
.ict-row { display: flex; gap: var(--ict-gap); height: ${ROW_H}px; margin: 0; padding: 0; list-style: none; }
.ict-item {
--c: ${PALETTE[0][0]};
position: relative; min-width: 0; min-height: 0;
flex: 0 0 var(--ict-cap);
transition: flex-grow var(--ict-ms) var(--ict-ease), flex-basis 380ms var(--ict-ease);
}
.ict-item[data-open] { flex-grow: 1; }
.ict-item[data-ink="light"] { --ink: #fff; }
.ict-item[data-ink="dark"] { --ink: #1b1915; }
/* The colored shape. A capsule sits a little shorter than the open card; it reaches full height when open. */
.ict-shape {
position: absolute; inset: 22px 0; overflow: hidden;
border-radius: calc(var(--ict-cap) / 2);
background: var(--c); color: var(--ink);
box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--ink) 10%, transparent);
transition: inset var(--ict-ms) var(--ict-ease), border-radius var(--ict-ms) var(--ict-ease);
}
.ict-item[data-open] .ict-shape { inset: 0; border-radius: var(--ict-r); }
/* The capsule face: the name written upward, the photo at the bottom. */
.ict-cap {
all: unset; position: absolute; inset: 0; cursor: pointer;
display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
gap: 10px; padding: 14px 6px 6px;
border-radius: inherit;
transition: opacity 260ms ease 220ms;
}
.ict-item[data-open] .ict-cap { opacity: 0; pointer-events: none; transition: opacity 160ms ease; }
.ict-cap:focus-visible { outline: 2px solid var(--ink); outline-offset: -4px; }
.ict-name {
flex: 0 1 auto; min-height: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
writing-mode: vertical-rl; transform: rotate(180deg);
font-size: 13px; font-weight: 500; line-height: 1; letter-spacing: -.005em;
}
/* The photo: a circle with a 6px ring of the capsule color around it (inner radius = outer radius - 6px). */
.ict-ph {
flex: none; position: relative; overflow: hidden; display: grid; place-items: center;
width: calc(var(--ict-cap) - 12px); height: calc(var(--ict-cap) - 12px);
border-radius: calc((var(--ict-cap) - 12px) / 2);
background: color-mix(in oklab, var(--ink) 14%, var(--c));
font-size: 15px; font-weight: 600;
transition: width 380ms var(--ict-ease), height 380ms var(--ict-ease), border-radius 380ms var(--ict-ease);
}
.ict-ph img, .ict-av img {
position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%;
user-select: none; -webkit-user-drag: none; pointer-events: none;
}
.ict-ph img { filter: saturate(.8); transform: scale(1.12); transition: filter 380ms ease, transform 380ms var(--ict-ease); }
/* Hover a capsule: it grows taller and wider, and the photo stretches into a tall portrait in full color. */
@media (hover: hover) {
.ict-item:not([data-open]):has(.ict-cap:hover) { flex-basis: ${CAP_HOVER}px; --ict-cap: ${CAP_HOVER}px; }
.ict-item:not([data-open]):has(.ict-cap:hover) .ict-shape { inset: 8px 0; }
.ict-item:not([data-open]) .ict-cap:hover .ict-ph { height: calc((var(--ict-cap) - 12px) * 1.45); }
.ict-item:not([data-open]) .ict-cap:hover .ict-ph img { filter: none; transform: scale(1); }
}
/* The open card. Its content is laid out at the full open width (set from the script),
so the words never re-wrap while the card grows: the card simply uncovers them. */
.ict-card {
position: absolute; top: 0; left: 0; bottom: 0; width: var(--ict-open-w, 100%);
display: flex; flex-direction: column; margin: 0; padding: 28px 30px 24px;
container: ict-card / inline-size;
opacity: 0; transition: opacity 220ms ease;
}
.ict-item[data-open] .ict-card { opacity: 1; transition: opacity 320ms ease 80ms; }
.ict-card:focus { outline: none; }
.ict-card:focus-visible { outline: 2px solid var(--ink); outline-offset: -6px; border-radius: var(--ict-r); }
.ict-top {
flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
transform-origin: 0 0;
opacity: ${TEXT_FROM.opacity}; transform: scale(${TEXT_FROM.scale});
transition: opacity 240ms ease, transform 240ms ease;
}
.ict-item[data-open][data-seen] .ict-top {
opacity: 1; transform: none;
transition: opacity 640ms ease 120ms, transform 760ms var(--ict-ease) 120ms;
}
.ict-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ict-mark { width: 32px; height: 32px; flex: none; }
.ict-date { font-size: 13px; line-height: 1; opacity: .7; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ict-quote {
margin: 20px 0 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; /* a very long quote scrolls inside the card */
font-size: 24px; line-height: 1.32; font-weight: 500; letter-spacing: -.02em; text-wrap: pretty; overflow-wrap: anywhere;
}
.ict-foot {
flex: none; display: flex; align-items: center; gap: 12px; margin-top: 20px; padding-top: 18px;
border-top: 1px solid color-mix(in oklab, var(--ink) 16%, transparent);
opacity: 0; transform: translateY(6px); transition: opacity 200ms ease, transform 200ms ease;
}
.ict-item[data-open][data-seen] .ict-foot { opacity: 1; transform: none; transition: opacity 420ms ease 220ms, transform 520ms var(--ict-ease) 220ms; }
.ict-av {
flex: none; position: relative; overflow: hidden; display: grid; place-items: center;
width: 40px; height: 40px; border-radius: 50%;
background: color-mix(in oklab, var(--ink) 14%, var(--c)); font-size: 14px; font-weight: 600;
}
.ict-who { min-width: 0; flex: 1 1 0; }
.ict-who b { display: block; font-size: 15px; line-height: 1.25; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ict-who span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; margin-top: 2px; font-size: 13px; line-height: 1.3; opacity: .72; overflow: hidden; overflow-wrap: anywhere; }
/* The stars pop in one after another. Unearned stars stay faint. */
.ict-stars { flex: none; display: flex; gap: 3px; }
.ict-star {
width: 16px; height: 16px; display: block;
opacity: 0; transform: scale(.3) rotate(-40deg);
transition: opacity 120ms ease, transform 120ms ease;
}
.ict-star[data-off] { --dim: .26; }
.ict-item[data-open][data-seen] .ict-star {
opacity: var(--dim, 1); transform: none;
transition: opacity 260ms ease, transform 520ms cubic-bezier(.34,1.56,.64,1);
transition-delay: calc(${STAR_DELAY}ms + var(--i) * ${STAR_STEP}ms);
}
/* A narrow open card (a small preview, or many reviews in a short row): smaller words, stars on their own line. */
@container ict-card (max-width: 360px) {
.ict-quote { font-size: 20px; }
.ict-foot { flex-wrap: wrap; row-gap: 14px; }
.ict-stars { order: -1; flex-basis: 100%; }
}
@container ict-card (max-width: 260px) {
.ict-quote { font-size: 17px; margin-top: 14px; }
}
.ict-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* Narrow sections: the capsules lie down and stack, photo on the left; the open card grows downward. */
@container (max-width: 559px) {
.ict-in { padding: 64px 16px; }
.ict-head { margin-bottom: 32px; }
.ict-title { font-size: 30px; }
.ict-desc { font-size: 16px; }
.ict-row { flex-direction: column; height: calc(${OPEN_H}px + (var(--ict-n, 6) - 1) * (var(--ict-cap) + var(--ict-gap))); }
.ict-shape { inset: 0 14px; }
.ict-item[data-open] .ict-shape { inset: 0; }
.ict-cap { flex-direction: row-reverse; justify-content: flex-end; padding: 6px 18px 6px 6px; }
.ict-name { writing-mode: horizontal-tb; transform: none; font-size: 14px; }
.ict-card { width: auto; right: 0; bottom: auto; height: var(--ict-open-h, ${OPEN_H}px); padding: 22px 20px 18px; }
.ict-quote { font-size: 19px; margin-top: 14px; }
.ict-mark { width: 26px; height: 26px; }
@media (hover: hover) {
.ict-item:not([data-open]):has(.ict-cap:hover) .ict-shape { inset: 0 6px; }
.ict-item:not([data-open]) .ict-cap:hover .ict-ph { height: calc(var(--ict-cap) - 12px); width: calc((var(--ict-cap) - 12px) * 1.45); }
}
}
@media (prefers-reduced-motion: reduce) {
.ict-item, .ict-shape, .ict-ph, .ict-ph img { transition-duration: 1ms !important; }
.ict-item[data-open][data-seen] .ict-top { transition: opacity 200ms ease; transform: none; }
.ict-top { transform: none; }
.ict-item[data-open][data-seen] .ict-star { transition: opacity 200ms ease; transition-delay: 0ms; }
.ict-star { transform: none; }
}
`;
/* Hugeicons quote, the two blocks filled. */
function QuoteMark() {
return (
<svg className="ict-mark" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={1.8} strokeLinecap="round" aria-hidden="true">
<path d="M14 16c0-1.886 0-2.828.586-3.414C15.172 12 16.114 12 18 12s2.828 0 3.414.586C22 13.172 22 14.114 22 16s0 2.828-.586 3.414C20.828 20 19.886 20 18 20s-2.828 0-3.414-.586C14 18.828 14 17.886 14 16Z" fill="currentColor" />
<path d="M14 16v-4.137C14 8.196 16.516 5.086 20 4" />
<path d="M2 16c0-1.886 0-2.828.586-3.414C3.172 12 4.114 12 6 12s2.828 0 3.414.586C10 13.172 10 14.114 10 16s0 2.828-.586 3.414C8.828 20 7.886 20 6 20s-2.828 0-3.414-.586C2 18.828 2 17.886 2 16Z" fill="currentColor" />
<path d="M2 16v-4.137C2 8.196 4.516 5.086 8 4" />
</svg>
);
}
/* Hugeicons star, filled. */
const STAR =
"M13.7276 3.44418L15.4874 6.99288C15.7274 7.48687 16.3673 7.9607 16.9073 8.05143L20.0969 8.58575C22.1367 8.92853 22.6167 10.4206 21.1468 11.8925L18.6671 14.3927C18.2471 14.8161 18.0172 15.6327 18.1471 16.2175L18.8571 19.3125C19.417 21.7623 18.1271 22.71 15.9774 21.4296L12.9877 19.6452C12.4478 19.3226 11.5579 19.3226 11.0079 19.6452L8.01827 21.4296C5.8785 22.71 4.57865 21.7522 5.13859 19.3125L5.84851 16.2175C5.97849 15.6327 5.74852 14.8161 5.32856 14.3927L2.84884 11.8925C1.389 10.4206 1.85895 8.92853 3.89872 8.58575L7.08837 8.05143C7.61831 7.9607 8.25824 7.48687 8.49821 6.99288L10.2581 3.44418C11.2179 1.51861 12.7777 1.51861 13.7276 3.44418Z";
function Stars({ rating }: { rating: number }) {
const r = Math.min(5, Math.max(0, Math.round(rating)));
return (
<span className="ict-stars">
{[0, 1, 2, 3, 4].map((i) => (
<svg key={i} className="ict-star" data-off={i >= r ? "" : undefined} style={{ "--i": i } as CSSProperties} viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
<path d={STAR} />
</svg>
))}
<span className="ict-sr">Rated {r} out of 5</span>
</span>
);
}
const initials = (name: string) =>
name
.trim()
.split(/\s+/)
.slice(0, 2)
.map((w) => Array.from(w)[0]?.toUpperCase() ?? "") // whole letters, so an emoji is never cut in half
.join("");
function Photo({ item, className }: { item: CapsuleTestimonial; className: string }) {
const [broken, setBroken] = useState(false);
const img = useRef<HTMLImageElement>(null);
// A new photo gets a fresh try. A photo can also fail before the page wakes up, when onError
// is not listening yet, so check once after.
useEffect(() => {
const el = img.current;
setBroken(Boolean(el && el.complete && el.naturalWidth === 0));
}, [item.photo]);
return (
<span className={className}>
{item.photo && !broken ? (
<img ref={img} src={item.photo} alt={item.alt ?? item.name} loading="lazy" decoding="async" draggable={false} onError={() => setBroken(true)} />
) : (
<span aria-hidden="true">{initials(item.name)}</span>
)}
</span>
);
}
/** Six made-up reviews, so it looks right before you add your own. Replace them with real ones. */
export const CAPSULE_TESTIMONIALS: CapsuleTestimonial[] = [
{
name: "Amara Okafor",
role: "Product Designer, Lumen Health",
quote: "I dropped in one section and the whole landing page finally felt finished. My developer asked which agency we hired.",
date: "Oct 2026",
rating: 5,
},
{
name: "Theo Marchetti",
role: "Founder, Pasta Labs",
quote: "We shipped the new pricing page on a Friday and nothing broke. In our team, that counts as a small miracle.",
date: "Sep 2026",
rating: 5,
},
{
name: "Hana Sato",
role: "Front-end Lead, Kumo",
quote: "The motion is calm the way good motion should be. I stopped tweaking easing curves at 2 a.m., and my sleep says thank you.",
date: "Sep 2026",
rating: 5,
},
{
name: "Diego Alvarez",
role: "Indie Maker",
quote: "Blend asked me four short questions, then it looked like I had designed it myself. I had not. One star off for making me look too good.",
date: "Aug 2026",
rating: 4,
},
{
name: "Priya Raman",
role: "Head of Brand, Northbeam",
quote: "Our brand team rejects most new components. This one passed review on the first try. I am still a little suspicious.",
date: "Jul 2026",
rating: 5,
},
{
name: "Jonas Weber",
role: "Developer, Fieldnote",
quote: "One file, no extra packages, works in dark mode. I read the source twice looking for the catch. There isn't one.",
date: "Jun 2026",
rating: 5,
},
];
export function CapsuleTestimonials({
items = CAPSULE_TESTIMONIALS,
title = "People said nice things. We kept them.",
description = "Real words from people who shipped with us. Open a capsule to read one.",
defaultOpen = 0,
open: openProp,
onOpenChange,
className,
style,
}: CapsuleTestimonialsProps) {
const list = Array.isArray(items) ? items : CAPSULE_TESTIMONIALS;
const n = Math.max(1, list.length);
const [open, setOpen] = useState(() => clampIndex(defaultOpen, n));
const [seen, setSeen] = useState(false);
const [size, setSize] = useState<{ w: number; h: number } | null>(null);
const row = useRef<HTMLUListElement>(null);
const cards = useRef<(HTMLElement | null)[]>([]);
const base = useId();
// A controlled open index wins; either way it stays valid if the list gets shorter.
const current = openProp === undefined ? Math.min(open, n - 1) : clampIndex(openProp, n);
// The open card's content is laid out at the full open size, so its words never re-wrap mid-animation.
useEffect(() => {
const el = row.current;
if (!el) return;
const measure = () => {
const cs = getComputedStyle(el);
const stacked = cs.flexDirection === "column";
const w = el.clientWidth;
const h = el.clientHeight;
const rest = (n - 1) * (CAP + GAP);
setSize(stacked ? { w, h: Math.max(0, h - rest) } : { w: Math.max(0, w - rest), h });
};
measure();
const ro = new ResizeObserver(measure);
ro.observe(el);
return () => ro.disconnect();
}, [n]);
// The first card's words and stars play when the section first comes into view.
useEffect(() => {
const el = row.current;
if (!el || seen) return;
if (typeof IntersectionObserver === "undefined") {
setSeen(true);
return;
}
const io = new IntersectionObserver(
([e]) => {
if (e.isIntersecting) {
setSeen(true);
io.disconnect();
}
},
{ threshold: 0.35 },
);
io.observe(el);
return () => io.disconnect();
}, [seen]);
const choose = useCallback(
(i: number, focus: boolean) => {
const next = ((i % n) + n) % n;
setSeen(true);
setOpen(next);
if (next !== current) onOpenChange?.(next);
// Keyboard and screen reader users land on the card they opened.
if (focus) requestAnimationFrame(() => cards.current[next]?.focus({ preventScroll: true }));
},
[n, current, onOpenChange],
);
const onKey = (e: KeyboardEvent<HTMLUListElement>) => {
const back = e.key === "ArrowLeft" || e.key === "ArrowUp";
const fwd = e.key === "ArrowRight" || e.key === "ArrowDown";
if (!back && !fwd && e.key !== "Home" && e.key !== "End") return;
e.preventDefault();
if (e.key === "Home") choose(0, true);
else if (e.key === "End") choose(n - 1, true);
else choose(current + (fwd ? 1 : -1), true);
};
const vars = {
"--ict-n": n,
...(size ? { "--ict-open-w": `${size.w}px`, "--ict-open-h": `${size.h}px` } : null),
} as CSSProperties;
// No reviews yet (still loading, or none): show nothing rather than an empty row or made-up ones.
if (!list.length) return null;
return (
<section className={className ? `ict ${className}` : "ict"} style={style} aria-label={typeof title === "string" ? title : "Testimonials"}>
<style>{CSS}</style>
<div className="ict-in">
{(title != null || description != null) && (
<div className="ict-head">
{title != null && <h2 className="ict-title">{title}</h2>}
{description != null && <p className="ict-desc">{description}</p>}
</div>
)}
<ul ref={row} className="ict-row" style={vars} onKeyDown={onKey}>
{list.map((item, i) => {
const isOpen = i === current;
const [palette, paletteInk] = PALETTE[i % PALETTE.length];
const color = item.color ?? palette;
const ink = item.ink ?? (item.color ? "dark" : paletteInk);
const cardId = `${base}-card-${i}`;
return (
<li
key={i}
className="ict-item"
data-open={isOpen ? "" : undefined}
data-seen={seen ? "" : undefined}
data-ink={ink}
style={{ "--c": color } as CSSProperties}
>
<div className="ict-shape">
<button
type="button"
className="ict-cap"
aria-expanded={isOpen}
aria-controls={cardId}
aria-label={`Read ${item.name}'s review`}
tabIndex={isOpen ? -1 : 0}
aria-hidden={isOpen || undefined}
onClick={(e) => choose(i, e.detail === 0)}
>
<span className="ict-name" aria-hidden="true">
{item.name}
</span>
<Photo item={{ ...item, alt: "" }} className="ict-ph" />
</button>
<figure
id={cardId}
ref={(el) => {
cards.current[i] = el;
}}
className="ict-card"
tabIndex={isOpen ? -1 : undefined}
aria-hidden={!isOpen || undefined}
inert={!isOpen || undefined}
>
<div className="ict-top">
<div className="ict-meta">
<QuoteMark />
{item.date != null && <span className="ict-date">{item.date}</span>}
</div>
<blockquote className="ict-quote">{item.quote}</blockquote>
</div>
<figcaption className="ict-foot">
<Photo item={item} className="ict-av" />
<span className="ict-who">
<b>{item.name}</b>
{item.role != null && <span>{item.role}</span>}
</span>
{typeof item.rating === "number" && Number.isFinite(item.rating) && <Stars rating={item.rating} />}
</figcaption>
</figure>
</div>
</li>
);
})}
</ul>
</div>
</section>
);
}
export default CapsuleTestimonials;
```
Usage
Put it after your features or pricing, where people want proof, and give it your own reviews and photos.
import { CapsuleTestimonials } from "@/components/ui/capsule-testimonials";
const REVIEWS = [
{ name: "Lena Fischer", role: "COO, Northwind", quote: "We moved our whole team over in a week.", date: "Oct 2026", rating: 5, photo: "/people/lena.jpg" },
{ name: "Omar Haddad", role: "Founder, Globex", quote: "Support answers before I finish typing.", date: "Sep 2026", rating: 5, photo: "/people/omar.jpg" },
{ name: "Mia Chen", role: "Designer, Initech", quote: "It finally looks like our brand.", date: "Aug 2026", rating: 4, photo: "/people/mia.jpg" },
{ name: "Sam Ortiz", role: "CTO, Umbrella", quote: "The fastest setup we have had all year.", date: "Jul 2026", rating: 5, photo: "/people/sam.jpg" },
];
export function Reviews() {
return <CapsuleTestimonials title="What our customers say" description="Open a capsule to read one." items={REVIEWS} />;
}Only one review is open at a time, and its words are laid out at the full card size, so they never re-wrap while it opens. Under 560px of width the capsules lie down and stack, so it works with a thumb on a phone. Page text comes from your theme: it reads --foreground and --background (or --fg and --bg), and the open card's corners are 3.5 times --radius-lg. Each card keeps its own color, so set color and ink to your brand variables if the soft palette doesn't fit. It pairs well with Window Stats higher up the same page.
Props
| Prop | Default | What it does |
|---|---|---|
items | 6 made-up reviews | The reviews, left to right: { name, role, quote, date, rating, photo, alt, color, ink }. 4 to 7 reads best. Portrait photos work best; without one, the capsule shows initials. An empty list shows nothing. |
items[].rating | — | Stars out of 5, whole numbers. They pop in one after another as the card opens. Leave it out to hide the stars. |
items[].color / ink | soft palette | The card color (any CSS color or theme variable) and its text, "light" or "dark". Six built-in colors take turns when you leave it out. |
title | "People said nice things. We kept them." | The heading above the row. null hides it. |
description | "Real words from people who shipped with us…" | The line under the heading. null hides it. |
defaultOpen | 0 | Which review starts open. |
open / onOpenChange | — | Control the open review yourself, for example to cycle them on a timer, and hear when someone opens one. |
className / style | — | On the section itself. It fills its width and centres an 896px column. |




