Skip to content
themes.dev
    Style: Wireframe

    Blocks · Marketing

    Testimonial

    One quote, large, with the person under it: a face, their name and their role. Initials stand in when there is no photo.

    16% of 671 home pages and 15% of 151 landing pages we studied have a testimonials section.

    What customers say

    “We used to plan releases around the deploy. Now nobody talks about it: we push, it is live, and on the one bad day we rolled back before support noticed.”

    Maren HoltHead of product, Ostra

    A customer without a photo

    “Setup took one afternoon, and most of that was reading the docs because we did not believe it was that short.”

    Idris CallowaySupport lead, Northpine

    Both previews render the same markup; the HTML tab below is that markup without a framework.

    Install

    React
    npx shadcn@latest add https://www.themes.dev/ui/r/testimonial.json
    Astro
    npx shadcn@latest add https://www.themes.dev/ui/r/astro/testimonial.json

    Or copy the files below into your project. They need clsx, tailwind-merge and the components they import, and the themes.dev UI theme. The HTML needs only the compiled CSS.

    testimonial.classes.ts
    /** Testimonial, single: one quote, large, with the person under it (a face, their name, their role and company). A
     *  <figure> with a <blockquote> and a <figcaption>. The portrait is decorative (alt="") because the name is right beside
     *  it; without a photo the person's initials stand in. The section has a visually hidden heading so it shows up in the
     *  page outline. */
    export const testimonial = {
      root: '@container bg-background px-6 py-16 text-foreground @3xl:py-24',
      inner: 'mx-auto max-w-3xl',
      heading: 'sr-only',
      figure: 'm-0 flex flex-col gap-8',
      quote: 'm-0 text-2xl leading-snug font-medium tracking-[-0.02em] text-balance @2xl:text-3xl',
      caption: 'flex items-center gap-4',
      face: 'size-14 shrink-0 overflow-hidden rounded-full bg-muted ring-1 ring-border',
      photo: 'size-full object-cover grayscale',
      initials: 'flex size-full items-center justify-center text-base font-medium text-muted-foreground',
      person: 'flex min-w-0 flex-col',
      name: 'text-base font-semibold not-italic',
      role: 'text-sm text-muted-foreground',
    };
    
    export type TestimonialContent = {
      quote: string;
      name: string;
      /** Role and company, one line ("Head of product, Ostra"). */
      role?: string;
      /** A square portrait; at least 112px for the 56px circle on a 2x screen. */
      photo?: { src: string; width?: number; height?: number };
      /** The hidden section heading. */
      label?: string;
      /** Unique on the page; ids the heading. */
      id: string;
    };
    
    /** "Maren Holt" → "MH". */
    export const initialsOf = (name: string) =>
      name
        .split(/\s+/)
        .filter(Boolean)
        .slice(0, 2)
        .map((p) => p[0]!.toUpperCase())
        .join('');
    testimonial.tsx
    import { cn } from '@/lib/utils';
    import { initialsOf, testimonial as c, type TestimonialContent } from './testimonial.classes';
    
    export type TestimonialProps = TestimonialContent & { className?: string };
    
    /** One quote, large, with the person under it: a face, their name and their role. */
    export function Testimonial({ quote, name, role, photo, label = 'What customers say', id, className }: TestimonialProps) {
      return (
        <section aria-labelledby={`${id}-title`} className={cn(c.root, className)}>
          <div className={c.inner}>
            <h2 id={`${id}-title`} className={c.heading}>{label}</h2>
            <figure className={c.figure}>
              <blockquote className={c.quote}><p>“{quote}”</p></blockquote>
              <figcaption className={c.caption}>
                <span className={c.face}>
                  {photo ? (
                    <img src={photo.src} width={photo.width ?? 112} height={photo.height ?? 112} alt="" loading="lazy" decoding="async" className={c.photo} />
                  ) : (
                    <span aria-hidden="true" className={c.initials}>{initialsOf(name)}</span>
                  )}
                </span>
                <span className={c.person}>
                  <cite className={c.name}>{name}</cite>
                  {role && <span className={c.role}>{role}</span>}
                </span>
              </figcaption>
            </figure>
          </div>
        </section>
      );
    }