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, OstraA 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.”
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, OstraA 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.”
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, 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('');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>
);
}---
import { cn } from '@/lib/utils';
import { initialsOf, testimonial as c, type TestimonialContent } from './testimonial.classes';
type Props = TestimonialContent & { class?: string };
const { quote, name, role, photo, label = 'What customers say', id, class: className } = Astro.props;
---
<section aria-labelledby={`${id}-title`} class={cn(c.root, className)}>
<div class={c.inner}>
<h2 id={`${id}-title`} class={c.heading}>{label}</h2>
<figure class={c.figure}>
<blockquote class={c.quote}><p>“{quote}”</p></blockquote>
<figcaption class={c.caption}>
<span class={c.face}>
{
photo ? (
<img src={photo.src} width={photo.width ?? 112} height={photo.height ?? 112} alt="" loading="lazy" decoding="async" class={c.photo} />
) : (
<span aria-hidden="true" class={c.initials}>{initialsOf(name)}</span>
)
}
</span>
<span class={c.person}>
<cite class={c.name}>{name}</cite>
{role && <span class={c.role}>{role}</span>}
</span>
</figcaption>
</figure>
</div>
</section>/** 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('');<section aria-labelledby="ex-quote-title" class="@container bg-background px-6 py-16 text-foreground @3xl:py-24">
<div class="mx-auto max-w-3xl">
<h2 id="ex-quote-title" class="sr-only">What customers say</h2>
<figure class="m-0 flex flex-col gap-8">
<blockquote class="m-0 text-2xl leading-snug font-medium tracking-[-0.02em] text-balance @2xl:text-3xl">
<p>
“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.”
</p>
</blockquote>
<figcaption class="flex items-center gap-4">
<span class="size-14 shrink-0 overflow-hidden rounded-full bg-muted ring-1 ring-border">
<img src="/ui/demo/people/maren-holt-square.webp" width="320" height="320" alt="" loading="lazy" decoding="async" class="size-full object-cover grayscale">
</span>
<span class="flex min-w-0 flex-col">
<cite class="text-base font-semibold not-italic">Maren Holt</cite>
<span class="text-sm text-muted-foreground">Head of product, Ostra</span>
</span>
</figcaption>
</figure>
</div>
</section>
<section aria-labelledby="ex-quote-initials-title" class="@container bg-background px-6 py-16 text-foreground @3xl:py-24 border-t">
<div class="mx-auto max-w-3xl">
<h2 id="ex-quote-initials-title" class="sr-only">A customer without a photo</h2>
<figure class="m-0 flex flex-col gap-8">
<blockquote class="m-0 text-2xl leading-snug font-medium tracking-[-0.02em] text-balance @2xl:text-3xl">
<p>“Setup took one afternoon, and most of that was reading the docs because we did not believe it was that short.”</p>
</blockquote>
<figcaption class="flex items-center gap-4">
<span class="size-14 shrink-0 overflow-hidden rounded-full bg-muted ring-1 ring-border">
<span aria-hidden="true" class="flex size-full items-center justify-center text-base font-medium text-muted-foreground">IC</span>
</span>
<span class="flex min-w-0 flex-col">
<cite class="text-base font-semibold not-italic">Idris Calloway</cite>
<span class="text-sm text-muted-foreground">Support lead, Northpine</span>
</span>
</figcaption>
</figure>
</div>
</section>