Testimonials Forge
Grid of client quote cards with an amber glow that follows the mouse inside each card. Token-only, follows the site theme, and the glow is scaled by --forge-glow so it is off on the Forge light theme.
pnpm dlx shadcn@latest add @leo/testimonials-forgeProps
| Name | Type | Default | Description |
|---|---|---|---|
| className | string | undefined | - | |
| contentClassName | string | undefined | - | Merged onto the content wrapper (header and cards), e.g. `mx-auto max-w-6xl md:px-6` to line it up with the page container. |
| description | string | undefined | Short notes from the people we built for. | |
| eyebrow | string | undefined | Clients | |
| items | TestimonialsForgeItem[] | undefined | [ { quote: "The new site loads instantly and our table bookings doubled in the first month.", author: "Mai Tran", business: "Bếp Nhà Mây", }, { quote: "They handled the catalogue, the photos and the launch, and we never had to chase them.", author: "Duc Pham", business: "Gạch Hạ Long", }, { quote: "Our dispatchers track every shipment from one screen, and the handover was spotless.", author: "Hanh Le", business: "An Phát Logistics", }, ] | Omit for the sample quotes; an empty array renders nothing. |
| reducedMotion | undefined | "respect" | "ignore" | respect | "ignore" keeps the glow fade for visitors who prefer reduced motion. |
| title | string | undefined | What clients say | Empty string hides the header (eyebrow and description too). |
Source
"use client";
import { useEffect, useRef } from "react";
import { useForgeMotion } from "@/hooks/use-forge-motion";
import { cn } from "@/lib/utils";
export interface TestimonialsForgeItem {
quote: string;
author: string;
/** Business name, e.g. "Bếp Nhà Mây". */
business?: string;
}
export interface TestimonialsForgeProps {
eyebrow?: string;
/** Empty string hides the header (eyebrow and description too). */
title?: string;
description?: string;
/** Omit for the sample quotes; an empty array renders nothing. */
items?: TestimonialsForgeItem[];
/** "ignore" keeps the glow fade for visitors who prefer reduced motion. */
reducedMotion?: "respect" | "ignore";
className?: string;
/** Merged onto the content wrapper (header and cards), e.g. `mx-auto max-w-6xl md:px-6` to line it up with the page container. */
contentClassName?: string;
}
const SAMPLE_ITEMS: TestimonialsForgeItem[] = [
{
quote: "The new site loads instantly and our table bookings doubled in the first month.",
author: "Mai Tran",
business: "Bếp Nhà Mây",
},
{
quote: "They handled the catalogue, the photos and the launch, and we never had to chase them.",
author: "Duc Pham",
business: "Gạch Hạ Long",
},
{
quote: "Our dispatchers track every shipment from one screen, and the handover was spotless.",
author: "Hanh Le",
business: "An Phát Logistics",
},
];
// Literal classes so Tailwind can see them.
const COLUMNS: Record<1 | 2 | 3, string> = {
1: "md:grid-cols-1",
2: "md:grid-cols-2",
3: "md:grid-cols-3",
};
const GLOW_OPACITY = "calc(var(--hover, 0) * var(--forge-glow, 1))";
const GLOW_GRADIENT =
"radial-gradient(400px circle at var(--x) var(--y), color-mix(in oklab, var(--primary) 18%, transparent), transparent 60%)";
const BORDER_GRADIENT =
"radial-gradient(400px circle at var(--x) var(--y), color-mix(in oklab, var(--primary) 60%, transparent), transparent 60%)";
const BORDER_MASK = "linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0)";
function Card({ item, animate }: { item: TestimonialsForgeItem; animate: boolean }) {
const ref = useRef<HTMLElement>(null);
const frame = useRef<number | null>(null);
const point = useRef({ x: 0, y: 0 });
useEffect(
() => () => {
if (frame.current !== null) cancelAnimationFrame(frame.current);
},
[],
);
const onMove = (e: React.PointerEvent<HTMLElement>) => {
// Touch has no hover, so a glow stuck under a finger would only mislead.
if (e.pointerType !== "mouse") return;
const el = ref.current;
if (!el) return;
const rect = el.getBoundingClientRect();
point.current = { x: e.clientX - rect.left, y: e.clientY - rect.top };
if (frame.current !== null) return;
frame.current = requestAnimationFrame(() => {
frame.current = null;
el.style.setProperty("--x", `${point.current.x}px`);
el.style.setProperty("--y", `${point.current.y}px`);
el.style.setProperty("--hover", "1");
});
};
const onLeave = () => {
if (frame.current !== null) {
cancelAnimationFrame(frame.current);
frame.current = null;
}
ref.current?.style.setProperty("--hover", "0");
};
const layer = cn("pointer-events-none absolute", animate && "transition-opacity duration-300");
return (
<figure
ref={ref}
onPointerMove={onMove}
onPointerLeave={onLeave}
className="relative flex flex-col rounded-[var(--radius)] border border-border p-6 md:p-8"
>
<div
aria-hidden="true"
className={cn(layer, "inset-0 rounded-[inherit]")}
style={{ background: GLOW_GRADIENT, opacity: GLOW_OPACITY }}
/>
<div
aria-hidden="true"
className={cn(layer, "-inset-px rounded-[inherit]")}
style={{
background: BORDER_GRADIENT,
opacity: GLOW_OPACITY,
padding: "1px",
mask: BORDER_MASK,
WebkitMask: BORDER_MASK,
WebkitMaskComposite: "xor",
}}
/>
<span
aria-hidden="true"
className="relative font-[family-name:var(--font-heading)] text-6xl leading-none text-primary"
>
“
</span>
<blockquote className="relative mt-4 flex-1 text-base text-foreground">
{item.quote}
</blockquote>
<figcaption className="relative mt-6 font-mono text-xs tracking-widest text-muted-foreground uppercase">
{item.author}
{item.business && (
<>
{/* The visible slash is hidden from assistive tech, so the spaces stay outside it. */}{" "}
<span aria-hidden="true">/</span> {item.business}
</>
)}
</figcaption>
</figure>
);
}
export default function TestimonialsForge({
eyebrow = "Clients",
title = "What clients say",
description = "Short notes from the people we built for.",
items = SAMPLE_ITEMS,
reducedMotion = "respect",
className,
contentClassName,
}: TestimonialsForgeProps) {
const { animate } = useForgeMotion(reducedMotion);
if (items.length === 0) return null;
const columns = Math.min(items.length, 3) as 1 | 2 | 3;
return (
<section className={cn("relative isolate bg-background text-foreground", className)}>
<div className={cn("px-6 py-16 md:px-12 md:py-24", contentClassName)}>
{title && (
<header className="mb-12">
<div className="max-w-2xl">
{eyebrow && (
<p className="font-mono text-xs tracking-widest text-primary uppercase">
{eyebrow}
</p>
)}
<h2 className="mt-3 font-[family-name:var(--font-heading)] text-3xl font-semibold tracking-tight sm:text-4xl">
{title}
</h2>
{description && <p className="mt-4 text-base text-muted-foreground">{description}</p>}
</div>
</header>
)}
<div className={cn("grid gap-6", COLUMNS[columns])}>
{items.map((item, i) => (
// biome-ignore lint/suspicious/noArrayIndexKey: items have no id and quotes may repeat
<Card key={i} item={item} animate={animate} />
))}
</div>
</div>
</section>
);
}