Masonry Testimonial Cards
A 3-column masonry of white rounded-2xl cards with hairline borders. Each holds quote text at about 17px, a 36px round avatar, a name and a muted source line (Trustpilot, Product Hunt, X). A centered 'Show more' pill sits below, and a large pull-quote with attribution precedes the grid.
Rebuilt from cal.com in the Warm Paper Calendar style.
Looks exactly like cal.com: brings its fonts and colours, namespaced so your own theme stays untouched.
Restyled to your project: uses your shadcn colours, fonts and radius, so it matches the rest of your app. Layout, type sizes and motion stay as designed.
Usage
Props: heading, subheading, items ({quote,name,source}[]), initialCount (cards shown before expanding) and moreLabel. Cards flow into three columns; clicking the pill reveals the rest.
components/testimonial-masonry-cards.tsx
"use client"; import { useEffect, useLayoutEffect, useRef, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react"; import { useState } from "react"; type Item = { quote: string; name: string; source: string }; const DEFAULT_ITEMS: Item[] = [ { quote: "We replaced three separate tools with this one and our weekly planning went from an hour to ten minutes. The onboarding was gentle and the team answered every question within the day.", name: "Marisol", source: "on Trustpilot" }, { quote: "Switched our whole studio over last month. Setup was painless, the templates are tidy, and nobody has asked to go back.", name: "Tobias R.", source: "@tobias_r on X" }, { quote: "One week in and I already can't imagine working without it.", name: "Lena Okafor", source: "@lenaok on X" }, { quote: "Clean, quick and refreshingly honest about what it does. It handles the boring parts so I can focus on the work itself. Highly recommend to any small team.", name: "hannesb", source: "on Trustpilot" }, { quote: "Finally a tool that feels calm. Fewer buttons, better defaults, and it just works on my phone as well.", name: "Priya Nair", source: "on Product Hunt" }, { quote: "Genuinely one of the nicest products I have tried this year, and I try a lot of them.", name: "Diego", source: "on Product Hunt" }, { quote: "The export options and open API are a dream for anyone who likes to tinker. We wired it into our reporting in an afternoon and it hasn't broken once since.", name: "Sam Whitfield", source: "@samwhit on X" }, { quote: "Support replied fast, fixed my issue, and even followed up the next morning to check it held.", name: "Odette", source: "on Trustpilot" }, { quote: "Easy to start, easy to share with the team. Only small gripe is the dark mode, but everything else is lovely.", name: "Yusuf Demir", source: "on Product Hunt" }, ]; const TONES = ["from-ink to-ink-deep", "from-blue to-hairline-strong", "from-sand to-paper", "from-success to-panel", "from-alert to-sand", "from-muted to-panel-alt"]; function initials(n: string) { return n.replace(/[^A-Za-z ]/g, "").split(" ").filter(Boolean).slice(0, 2).map((s) => s[0].toUpperCase()).join(""); } export default function MasonryTestimonialCards({ heading = "Loved by teams who value their time.", subheading = "Hear straight from the people who use it every single day.", items = DEFAULT_ITEMS, initialCount = 6, moreLabel = "Show more", }: { heading?: string; subheading?: string; items?: Item[]; initialCount?: number; moreLabel?: string; }) { const [expanded, setExpanded] = useState(false); const visible = expanded ? items : items.slice(0, initialCount); const cols: Item[][] = [[], [], []]; const idx: number[][] = [[], [], []]; visible.forEach((it, i) => { cols[i % 3].push(it); idx[i % 3].push(i); }); const Card = ({ it, i }: { it: Item; i: number }) => ( <figure className="m-0 rounded-xl border border-hairline bg-canvas p-6"> <blockquote className="m-0 text-[17px] leading-[1.45] text-ink">{it.quote}</blockquote> <figcaption className="mt-6 flex items-center gap-3"> <span aria-hidden className={`flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-gradient-to-br ${TONES[i % TONES.length]} text-[11px] font-medium text-canvas`}>{initials(it.name)}</span> <span className="flex flex-col leading-tight"> <span className="text-ui text-ink">{it.name}</span> <span className="text-caption text-muted">{it.source}</span> </span> </figcaption> </figure> ); return ( <section className="bg-canvas px-5 py-20 font-sans md:px-[74px] md:py-28"> <div className="mx-auto max-w-[1292px]"> <Reveal from="up" delay={60} duration={600}> <h2 className="max-w-[640px] font-display text-h1 tracking-[-0.04em] text-ink-deep">{heading}</h2> </Reveal> <Reveal from="up" delay={120} duration={600}> <p className="mt-6 max-w-[620px] font-display text-lead text-soft">{subheading}</p> </Reveal> <div className="mt-16 grid gap-4 md:grid-cols-3"> {cols.map((col, c) => ( <div key={c} className="flex flex-col gap-4"> {col.map((it, j) => ( <Card key={idx[c][j]} it={it} i={idx[c][j]} /> ))} </div> ))} </div> {!expanded && items.length > initialCount && ( <div className="mt-14 flex justify-center"> <button type="button" onClick={() => setExpanded(true)} className="rounded-pill border border-hairline bg-canvas px-4 py-2 text-ui text-ink shadow-soft transition-colors duration-color-transition ease-color-transition hover:bg-panel focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ink" > {moreLabel} </button> </div> )} </div> </section> ); } // ---- Yoink motion (inlined, no dependencies): Reveal, Stagger ---- const YK_EASE = "cubic-bezier(0.16, 1, 0.3, 1)"; const useYkLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect; function ykReducedMotion(): boolean { return typeof window !== "undefined" && !!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches; } // "idle": untouched (visible) · "hidden": waiting below the fold · "shown": play the entrance. // Content is only hidden once we know we can show it again (IntersectionObserver exists, motion allowed, // and there is a box to watch), and a safety net reveals anything on screen that is still hidden. type YkRevealState = "idle" | "hidden" | "shown"; function useYkReveal(ref: RefObject<Element | null>, once = true): YkRevealState { const [state, setState] = useState<YkRevealState>("idle"); useYkLayoutEffect(() => { const el = ref.current; if (!el || ykReducedMotion() || typeof IntersectionObserver === "undefined") return; // watch the element's own box, or its children when it has none (display: contents) const boxes = () => (getComputedStyle(el).display === "contents" ? Array.from(el.children) : [el]); const onScreen = (t: Element) => { const r = t.getBoundingClientRect(); return (r.width > 0 || r.height > 0) && r.bottom > 0 && r.right > 0 && r.top < window.innerHeight && r.left < window.innerWidth; }; if (!boxes().some((t) => t.getBoundingClientRect().width > 0 || t.getBoundingClientRect().height > 0)) return; // e.g. hidden at mount: leave it visible let shown = false; const show = (v: boolean) => { if (v !== shown) (shown = v), setState(v ? "shown" : "hidden"); }; setState("hidden"); const inView = new Set<Element>(); const io = new IntersectionObserver((entries) => { for (const e of entries) { if (e.isIntersecting) inView.add(e.target); else inView.delete(e.target); } if (inView.size) { show(true); if (once) io.disconnect(); } else if (!once) show(false); }); const watched = new Set<Element>(); const watch = () => boxes().forEach((t) => !watched.has(t) && (watched.add(t), io.observe(t))); watch(); // safety net: styles that land after mount (display: contents) get watched too, and nothing // stays hidden for more than a moment while it is actually on screen const start = Date.now(); const net = setInterval(() => { if (shown) return once && clearInterval(net); watch(); if (Date.now() - start > 2400 && boxes().some(onScreen)) show(true); }, 600); return () => { io.disconnect(); clearInterval(net); }; }, [once]); return state; } type YkRevealFrom = "up" | "down" | "left" | "right" | "scale" | "blur" | "none"; /** Fades content in as it scrolls into view. */ function Reveal({ children, from = "up", delay = 0, duration = 700, distance = 24, once = true, as = "div", className, style, }: { children?: ReactNode; from?: YkRevealFrom; delay?: number; duration?: number; distance?: number; once?: boolean; as?: ElementType; className?: string; style?: CSSProperties; }) { const Tag = as; const ref = useRef<HTMLElement>(null); const state = useYkReveal(ref, once); const hidden = state === "hidden"; const offset = { up: `translate3d(0, ${distance}px, 0)`, down: `translate3d(0, ${-distance}px, 0)`, left: `translate3d(${-distance}px, 0, 0)`, right: `translate3d(${distance}px, 0, 0)`, scale: "scale(0.94)", blur: `translate3d(0, ${distance / 2}px, 0)`, none: "none", }[from]; const t = `${duration}ms ${YK_EASE} ${delay}ms`; return ( <Tag ref={ref} className={className} style={{ ...style, ...(hidden && { opacity: 0, transform: offset, filter: from === "blur" ? "blur(12px)" : undefined }), ...(state === "shown" && { transition: `opacity ${t}, transform ${t}, filter ${t}` }), }} > {children} </Tag> ); } /** Reveals each direct child one after another when the group scrolls into view. */ function Stagger({ children, step = 90, from = "up", distance = 20, duration = 650, delay = 0, once = true, as = "div", className, style, }: { children?: ReactNode; step?: number; from?: "up" | "down" | "left" | "right" | "scale" | "fade"; distance?: number; duration?: number; delay?: number; once?: boolean; as?: ElementType; className?: string; style?: CSSProperties; }) { const Tag = as; const ref = useRef<HTMLElement>(null); const state = useYkReveal(ref, once); useYkLayoutEffect(() => { const items = Array.from(ref.current?.children ?? []) as HTMLElement[]; if (state === "idle") return; const offset = { up: `translate3d(0, ${distance}px, 0)`, down: `translate3d(0, ${-distance}px, 0)`, left: `translate3d(${-distance}px, 0, 0)`, right: `translate3d(${distance}px, 0, 0)`, scale: "scale(0.92)", fade: "none", }[from]; if (state === "hidden") { for (const el of items) Object.assign(el.style, { transition: "none", opacity: "0", transform: offset }); return; } items.forEach((el, i) => { const t = `${duration}ms ${YK_EASE} ${delay + i * step}ms`; Object.assign(el.style, { transition: `opacity ${t}, transform ${t}`, opacity: "", transform: "" }); }); // hand the children their own transitions back once everything has landed const done = setTimeout(() => items.forEach((el) => (el.style.transition = "")), delay + items.length * step + duration + 50); return () => clearTimeout(done); }, [state]); return ( <Tag ref={ref} className={className} style={style}> {children} </Tag> ); }"use client"; import { useEffect, useLayoutEffect, useRef, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react"; import { useState } from "react"; type Item = { quote: string; name: string; source: string }; const DEFAULT_ITEMS: Item[] = [ { quote: "We replaced three separate tools with this one and our weekly planning went from an hour to ten minutes. The onboarding was gentle and the team answered every question within the day.", name: "Marisol", source: "on Trustpilot" }, { quote: "Switched our whole studio over last month. Setup was painless, the templates are tidy, and nobody has asked to go back.", name: "Tobias R.", source: "@tobias_r on X" }, { quote: "One week in and I already can't imagine working without it.", name: "Lena Okafor", source: "@lenaok on X" }, { quote: "Clean, quick and refreshingly honest about what it does. It handles the boring parts so I can focus on the work itself. Highly recommend to any small team.", name: "hannesb", source: "on Trustpilot" }, { quote: "Finally a tool that feels calm. Fewer buttons, better defaults, and it just works on my phone as well.", name: "Priya Nair", source: "on Product Hunt" }, { quote: "Genuinely one of the nicest products I have tried this year, and I try a lot of them.", name: "Diego", source: "on Product Hunt" }, { quote: "The export options and open API are a dream for anyone who likes to tinker. We wired it into our reporting in an afternoon and it hasn't broken once since.", name: "Sam Whitfield", source: "@samwhit on X" }, { quote: "Support replied fast, fixed my issue, and even followed up the next morning to check it held.", name: "Odette", source: "on Trustpilot" }, { quote: "Easy to start, easy to share with the team. Only small gripe is the dark mode, but everything else is lovely.", name: "Yusuf Demir", source: "on Product Hunt" }, ]; const TONES = ["from-foreground to-foreground", "from-foreground to-border", "from-foreground to-muted", "from-warm-success to-card", "from-warm-alert to-foreground", "from-foreground to-muted"]; function initials(n: string) { return n.replace(/[^A-Za-z ]/g, "").split(" ").filter(Boolean).slice(0, 2).map((s) => s[0].toUpperCase()).join(""); } export default function MasonryTestimonialCards({ heading = "Loved by teams who value their time.", subheading = "Hear straight from the people who use it every single day.", items = DEFAULT_ITEMS, initialCount = 6, moreLabel = "Show more", }: { heading?: string; subheading?: string; items?: Item[]; initialCount?: number; moreLabel?: string; }) { const [expanded, setExpanded] = useState(false); const visible = expanded ? items : items.slice(0, initialCount); const cols: Item[][] = [[], [], []]; const idx: number[][] = [[], [], []]; visible.forEach((it, i) => { cols[i % 3].push(it); idx[i % 3].push(i); }); const Card = ({ it, i }: { it: Item; i: number }) => ( <figure className="m-0 rounded-2xl border border-border bg-background p-6"> <blockquote className="m-0 text-[17px] leading-[1.45] text-foreground">{it.quote}</blockquote> <figcaption className="mt-6 flex items-center gap-3"> <span aria-hidden className={`flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-gradient-to-br ${TONES[i % TONES.length]} text-[11px] font-medium text-background`}>{initials(it.name)}</span> <span className="flex flex-col leading-tight"> <span className="text-warm-ui text-foreground">{it.name}</span> <span className="text-warm-caption text-muted-foreground">{it.source}</span> </span> </figcaption> </figure> ); return ( <section className="bg-background px-5 py-20 font-sans md:px-[74px] md:py-28"> <div className="mx-auto max-w-[1292px]"> <Reveal from="up" delay={60} duration={600}> <h2 className="max-w-[640px] font-sans text-warm-h1 tracking-[-0.04em] text-muted-foreground">{heading}</h2> </Reveal> <Reveal from="up" delay={120} duration={600}> <p className="mt-6 max-w-[620px] font-sans text-warm-lead text-muted-foreground">{subheading}</p> </Reveal> <div className="mt-16 grid gap-4 md:grid-cols-3"> {cols.map((col, c) => ( <div key={c} className="flex flex-col gap-4"> {col.map((it, j) => ( <Card key={idx[c][j]} it={it} i={idx[c][j]} /> ))} </div> ))} </div> {!expanded && items.length > initialCount && ( <div className="mt-14 flex justify-center"> <button type="button" onClick={() => setExpanded(true)} className="rounded-full border border-border bg-background px-4 py-2 text-warm-ui text-foreground shadow-warm-soft transition-colors duration-warm-color-transition ease-warm-color-transition hover:bg-card focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-foreground" > {moreLabel} </button> </div> )} </div> </section> ); } // ---- Yoink motion (inlined, no dependencies): Reveal, Stagger ---- const YK_EASE = "cubic-bezier(0.16, 1, 0.3, 1)"; const useYkLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect; function ykReducedMotion(): boolean { return typeof window !== "undefined" && !!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches; } // "idle": untouched (visible) · "hidden": waiting below the fold · "shown": play the entrance. // Content is only hidden once we know we can show it again (IntersectionObserver exists, motion allowed, // and there is a box to watch), and a safety net reveals anything on screen that is still hidden. type YkRevealState = "idle" | "hidden" | "shown"; function useYkReveal(ref: RefObject<Element | null>, once = true): YkRevealState { const [state, setState] = useState<YkRevealState>("idle"); useYkLayoutEffect(() => { const el = ref.current; if (!el || ykReducedMotion() || typeof IntersectionObserver === "undefined") return; // watch the element's own box, or its children when it has none (display: contents) const boxes = () => (getComputedStyle(el).display === "contents" ? Array.from(el.children) : [el]); const onScreen = (t: Element) => { const r = t.getBoundingClientRect(); return (r.width > 0 || r.height > 0) && r.bottom > 0 && r.right > 0 && r.top < window.innerHeight && r.left < window.innerWidth; }; if (!boxes().some((t) => t.getBoundingClientRect().width > 0 || t.getBoundingClientRect().height > 0)) return; // e.g. hidden at mount: leave it visible let shown = false; const show = (v: boolean) => { if (v !== shown) (shown = v), setState(v ? "shown" : "hidden"); }; setState("hidden"); const inView = new Set<Element>(); const io = new IntersectionObserver((entries) => { for (const e of entries) { if (e.isIntersecting) inView.add(e.target); else inView.delete(e.target); } if (inView.size) { show(true); if (once) io.disconnect(); } else if (!once) show(false); }); const watched = new Set<Element>(); const watch = () => boxes().forEach((t) => !watched.has(t) && (watched.add(t), io.observe(t))); watch(); // safety net: styles that land after mount (display: contents) get watched too, and nothing // stays hidden for more than a moment while it is actually on screen const start = Date.now(); const net = setInterval(() => { if (shown) return once && clearInterval(net); watch(); if (Date.now() - start > 2400 && boxes().some(onScreen)) show(true); }, 600); return () => { io.disconnect(); clearInterval(net); }; }, [once]); return state; } type YkRevealFrom = "up" | "down" | "left" | "right" | "scale" | "blur" | "none"; /** Fades content in as it scrolls into view. */ function Reveal({ children, from = "up", delay = 0, duration = 700, distance = 24, once = true, as = "div", className, style, }: { children?: ReactNode; from?: YkRevealFrom; delay?: number; duration?: number; distance?: number; once?: boolean; as?: ElementType; className?: string; style?: CSSProperties; }) { const Tag = as; const ref = useRef<HTMLElement>(null); const state = useYkReveal(ref, once); const hidden = state === "hidden"; const offset = { up: `translate3d(0, ${distance}px, 0)`, down: `translate3d(0, ${-distance}px, 0)`, left: `translate3d(${-distance}px, 0, 0)`, right: `translate3d(${distance}px, 0, 0)`, scale: "scale(0.94)", blur: `translate3d(0, ${distance / 2}px, 0)`, none: "none", }[from]; const t = `${duration}ms ${YK_EASE} ${delay}ms`; return ( <Tag ref={ref} className={className} style={{ ...style, ...(hidden && { opacity: 0, transform: offset, filter: from === "blur" ? "blur(12px)" : undefined }), ...(state === "shown" && { transition: `opacity ${t}, transform ${t}, filter ${t}` }), }} > {children} </Tag> ); } /** Reveals each direct child one after another when the group scrolls into view. */ function Stagger({ children, step = 90, from = "up", distance = 20, duration = 650, delay = 0, once = true, as = "div", className, style, }: { children?: ReactNode; step?: number; from?: "up" | "down" | "left" | "right" | "scale" | "fade"; distance?: number; duration?: number; delay?: number; once?: boolean; as?: ElementType; className?: string; style?: CSSProperties; }) { const Tag = as; const ref = useRef<HTMLElement>(null); const state = useYkReveal(ref, once); useYkLayoutEffect(() => { const items = Array.from(ref.current?.children ?? []) as HTMLElement[]; if (state === "idle") return; const offset = { up: `translate3d(0, ${distance}px, 0)`, down: `translate3d(0, ${-distance}px, 0)`, left: `translate3d(${-distance}px, 0, 0)`, right: `translate3d(${distance}px, 0, 0)`, scale: "scale(0.92)", fade: "none", }[from]; if (state === "hidden") { for (const el of items) Object.assign(el.style, { transition: "none", opacity: "0", transform: offset }); return; } items.forEach((el, i) => { const t = `${duration}ms ${YK_EASE} ${delay + i * step}ms`; Object.assign(el.style, { transition: `opacity ${t}, transform ${t}`, opacity: "", transform: "" }); }); // hand the children their own transitions back once everything has landed const done = setTimeout(() => items.forEach((el) => (el.style.transition = "")), delay + items.length * step + duration + 50); return () => clearTimeout(done); }, [state]); return ( <Tag ref={ref} className={className} style={style}> {children} </Tag> ); }
Quality checks
Automated, in a real browser · 4d ago- Accessible: passedNo serious accessibility problems (axe-core): readable contrast, labelled buttons and images.
- Responsive: passedRenders at phone (390px), tablet (768px) and desktop width without sideways scrolling.
- Dark mode: passedStill readable when installed in your theme and switched to dark mode.
- Themeable: passedUses design tokens rather than hard-coded colours, so it follows your theme cleanly.
- Animates cleanly: passedIts animation plays and finishes with everything visible, and it stays still for people who turn on reduced motion.