Testimonial wall

A masonry wall of customer quotes in CSS columns (one, two or three by width), each a figure with a blockquote, an initials avatar tinted from your chart tokens, a name and a role at the company. One quote can be featured larger on a primary-colour card. Long walls start collapsed under a soft fade with a Show all button that reports its state to assistive technology.

MarketingBlockTailwind v4

Source

"use client";

import { useId, useState } from "react";
import { ChevronDown } from "lucide-react";
import { cn } from "@/lib/utils";

export type Testimonial = {
  quote: string;
  name: string;
  role: string;
  company: string;
  /** Set the quote larger, on a primary-colour card. Use once per wall. */
  featured?: boolean;
};

export type TestimonialWallProps = {
  title?: string;
  description?: string;
  testimonials?: Testimonial[];
  /** Height of the wall before "Show all", in pixels. Set to 0 to always show everything. */
  collapsedHeight?: number;
  className?: string;
};

const DEFAULT_TESTIMONIALS: Testimonial[] = [
  {
    quote: "We moved 40 runbooks over in a week. On-call handoffs that used to take an hour now take ten minutes, because everything sits on one page.",
    name: "Mara Reyes",
    role: "Head of SRE",
    company: "Copperline Freight",
    featured: true,
  },
  { quote: "The import kept every internal link intact. That alone saved us a month of cleanup.", name: "Tomasz Olsen", role: "Engineering Manager", company: "Mossgate Health" },
  { quote: "Page-level permissions let us share specs with contractors without opening up the whole workspace.", name: "Ama Kyei", role: "Product Lead", company: "Northvane" },
  { quote: "Search is the feature people mention. Three letters in, and the page is already at the top.", name: "Jun Li", role: "Staff Engineer", company: "Plover Bank" },
  { quote: "Our support team writes its macros in Paperlark now. New hires answer tickets on their second day.", name: "Sofia Park", role: "Support Operations", company: "Orchard Row" },
  { quote: "Offline mode sounds minor until you are on a site visit with no signal and the checklist still opens.", name: "Dev Nair", role: "Field Engineer", company: "Saltmarsh Energy" },
  { quote: "Billing only counts people who edited that month, so we stopped auditing seats every quarter.", name: "Lena Hartmann", role: "Finance Director", company: "Brindle Labs" },
  { quote: "We tried three wikis in two years. This is the first one the sales team opens without being asked.", name: "Owen Clarke", role: "VP Sales", company: "Kestrel & Co" },
  { quote: "Version history saved a launch. Someone deleted the rollback section at 2 a.m. and we had it back in one click.", name: "Priya Raman", role: "Release Manager", company: "Halden Ledger" },
  { quote: "Comments resolve into the page instead of piling up in chat. Our review threads finally end.", name: "Felix Moreau", role: "Design Director", company: "Tern Studio" },
];

const initials = (name: string) => name.split(" ").map((part) => part[0]).slice(0, 2).join("");

export function TestimonialWall({
  title = "Teams that switched, in their own words",
  description = "From 1,240 reviews by workspace admins, average 4.8 out of 5.",
  testimonials = DEFAULT_TESTIMONIALS,
  collapsedHeight = 760,
  className,
}: TestimonialWallProps) {
  const wallId = useId();
  const [expanded, setExpanded] = useState(false);
  const collapsible = collapsedHeight > 0;
  const collapsed = collapsible && !expanded;

  return (
    <section aria-labelledby="testimonial-wall-title" className={cn("bg-background px-4 py-20 sm:px-6 lg:px-8 lg:py-28", className)}>
      <div className="mx-auto max-w-6xl">
        <div className="max-w-2xl">
          <h2 id="testimonial-wall-title" className="text-balance text-4xl font-semibold tracking-[-0.035em] text-foreground sm:text-5xl">
            {title}
          </h2>
          {description && <p className="mt-4 text-lg leading-relaxed text-muted-foreground">{description}</p>}
        </div>

        <div className="relative mt-12 lg:mt-16">
          {/* The clip sits on a wrapper: a height limit on the columns themselves would push cards into hidden extra columns. */}
          <div
            id={wallId}
            style={collapsed ? { maxHeight: collapsedHeight } : undefined}
            className={cn(collapsed && "overflow-hidden [mask-image:linear-gradient(to_bottom,#000_65%,transparent)]")}
          >
            <div className="columns-1 gap-4 sm:columns-2 lg:columns-3">
              {testimonials.map((item, index) => (
                <figure
                  key={item.name}
                  className={cn(
                    "mb-4 break-inside-avoid rounded-xl p-6 sm:p-7",
                    item.featured ? "bg-primary text-primary-foreground" : "bg-muted/60 text-foreground dark:bg-muted/30",
                  )}
                >
                  <blockquote className={cn(item.featured ? "text-xl leading-snug tracking-tight sm:text-2xl" : "text-[0.9375rem] leading-relaxed")}>
                    <p>“{item.quote}”</p>
                  </blockquote>
                  <figcaption className={cn("flex items-center gap-3", item.featured ? "mt-8" : "mt-6")}>
                    <span
                      aria-hidden="true"
                      className={cn(
                        "grid size-10 shrink-0 place-items-center rounded-full text-xs font-semibold",
                        item.featured ? "bg-primary-foreground/15 text-primary-foreground" : "text-foreground",
                      )}
                      style={item.featured ? undefined : { background: `color-mix(in oklab, var(--chart-${(index % 5) + 1}) 26%, var(--background))` }}
                    >
                      {initials(item.name)}
                    </span>
                    <span className="min-w-0 text-sm">
                      <span className="block font-semibold">{item.name}</span>
                      <span className={cn("block", item.featured ? "text-primary-foreground/70" : "text-muted-foreground")}>
                        {item.role}, {item.company}
                      </span>
                    </span>
                  </figcaption>
                </figure>
              ))}
            </div>
          </div>

          {collapsible && (
            <div className={cn("flex justify-center", collapsed ? "absolute inset-x-0 bottom-0" : "mt-6")}>
              <button
                type="button"
                aria-expanded={expanded}
                aria-controls={wallId}
                onClick={() => setExpanded((value) => !value)}
                className="inline-flex h-10 items-center gap-2 rounded-md bg-background px-4 text-sm font-medium text-foreground ring-1 ring-border transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
              >
                {expanded ? "Show fewer" : `Show all ${testimonials.length}`}
                <ChevronDown className={cn("size-4 motion-safe:transition-transform", expanded && "rotate-180")} aria-hidden="true" />
              </button>
            </div>
          )}
        </div>
      </div>
    </section>
  );
}