# Proof Hero
*URL: https://www.grettech.com/components/proof-hero*

A centred hero ringed by drifting customer quotes over a grid of flickering squares that brightens around the cursor and falls quiet behind the title.

- Canvas grid of flickering squares, lit up around the cursor
- Up to six glassy quote cards with stars, drifting gently
- Quiet zone keeps the title readable
- 24fps cap, paused off-screen; still for reduced motion

## Install with the shadcn CLI
```bash
npx shadcn@latest add https://www.grettech.com/api/registry/proof-hero
```
With its demo: `npx shadcn@latest add https://www.grettech.com/api/registry/proof-hero-demo`

**Dependencies:** npm: motion, clsx, tailwind-merge

## Manual installation
**Step 1: Install dependencies**
Install the packages this component uses and the shadcn/ui components it builds on. It also needs the `cn` helper in `lib/utils.ts`, which `npx shadcn@latest init` adds.

```bash
npm install motion clsx tailwind-merge
```

**Step 2: Copy the source code**
Add these files to your project components directory.

File: `components/ui/proof-hero.tsx`
```tsx
"use client"

import { cn } from "@/lib/utils"
import { motion, useReducedMotion } from "motion/react"
import * as React from "react"

export type ProofQuote = {
  name: string
  quote: string
  /** Photo URL; initials are shown without one */
  avatar?: string
}

export interface ProofHeroProps extends Omit<
  React.HTMLAttributes<HTMLElement>,
  "title"
> {
  /** Small line above the title */
  eyebrow?: string
  title: React.ReactNode
  description?: string
  /** Up to six quotes, placed around the edges from the top left */
  quotes?: ProofQuote[]
  /** Calls to action or a form, below the description */
  children?: React.ReactNode
  /** Let the cards float gently */
  drift?: boolean
  /** Flickering grid of squares behind everything */
  flicker?: boolean
  /** Colour of the squares; defaults to the text colour */
  flickerColor?: string
}

// Where each card sits, as % of the hero. Cards partly leave the frame,
// which reads as "there's more" without crowding the title.
const SLOTS = [
  "md:flex left-[-3%] top-[9%] -rotate-2",
  "md:flex right-[-5%] top-[13%] rotate-2",
  "lg:flex left-[-7%] top-[45%] rotate-1",
  "lg:flex right-[-3%] top-[49%] -rotate-1",
  "md:flex left-[3%] bottom-[8%] rotate-1",
  "md:flex right-[1%] bottom-[10%] -rotate-2",
]

const REDUCED = "(prefers-reduced-motion: reduce)"

const initials = (name: string) =>
  name
    .split(/\s+/)
    .map((part) => part[0])
    .slice(0, 2)
    .join("")
    .toUpperCase()

/**
 * A grid of small squares that flicker at random and brighten around the
 * cursor. Drawn at device resolution, capped at 24fps, paused off-screen
 * and in background tabs; a still grid for reduced motion.
 */
function FlickerGrid({
  color,
  pointer,
}: {
  color?: string
  pointer: React.RefObject<{ x: number; y: number } | null>
}) {
  const wrap = React.useRef<HTMLDivElement>(null)
  const canvas = React.useRef<HTMLCanvasElement>(null)

  React.useEffect(() => {
    const el = canvas.current
    const box = wrap.current
    const ctx = el?.getContext("2d")
    if (!el || !box || !ctx) return
    const SQUARE = 3
    const CELL = 12
    const MAX = 0.26
    const CHANCE = 0.28
    let cols = 0
    let rows = 0
    let cells = new Float32Array(0)
    let fill = color || getComputedStyle(box).color
    let frame = 0
    let last = 0
    let visible = true
    const still = window.matchMedia(REDUCED).matches

    const draw = () => {
      const dpr = Math.min(2, window.devicePixelRatio || 1)
      ctx.setTransform(dpr, 0, 0, dpr, 0, 0)
      ctx.clearRect(0, 0, cols * CELL, rows * CELL)
      ctx.fillStyle = fill
      const p = pointer.current
      for (let i = 0; i < cols; i++) {
        for (let j = 0; j < rows; j++) {
          let a = cells[i * rows + j]
          if (p) {
            const dx = i * CELL - p.x
            const dy = j * CELL - p.y
            const d = Math.sqrt(dx * dx + dy * dy)
            if (d < 140) a = Math.max(a, (1 - d / 140) * 0.7)
          }
          if (a < 0.02) continue
          ctx.globalAlpha = a
          ctx.fillRect(i * CELL, j * CELL, SQUARE, SQUARE)
        }
      }
      ctx.globalAlpha = 1
    }
    const resize = () => {
      const rect = box.getBoundingClientRect()
      const dpr = Math.min(2, window.devicePixelRatio || 1)
      cols = Math.ceil(rect.width / CELL)
      rows = Math.ceil(rect.height / CELL)
      el.width = Math.round(rect.width * dpr)
      el.height = Math.round(rect.height * dpr)
      cells = new Float32Array(cols * rows).map(() => Math.random() * MAX)
      fill = color || getComputedStyle(box).color
      draw()
    }
    const loop = (time: number) => {
      frame = requestAnimationFrame(loop)
      if (!visible || document.hidden || time - last < 1000 / 24) return
      const dt = Math.min(0.1, (time - last) / 1000)
      last = time
      for (let k = 0; k < cells.length; k++)
        if (Math.random() < CHANCE * dt) cells[k] = Math.random() * MAX
      draw()
    }

    const sizer = new ResizeObserver(resize)
    sizer.observe(box)
    const seen = new IntersectionObserver(([entry]) => {
      visible = entry?.isIntersecting ?? true
    })
    seen.observe(box)
    // Follow theme changes when the squares use the text colour
    const theme = new MutationObserver(() => {
      fill = color || getComputedStyle(box).color
      draw()
    })
    theme.observe(document.documentElement, {
      attributes: true,
      attributeFilter: ["class", "style"],
    })
    resize()
    if (!still) frame = requestAnimationFrame(loop)
    return () => {
      cancelAnimationFrame(frame)
      sizer.disconnect()
      seen.disconnect()
      theme.disconnect()
    }
  }, [color, pointer])

  return (
    <div
      ref={wrap}
      aria-hidden="true"
      className="absolute inset-0 [mask-image:radial-gradient(ellipse_62%_58%_at_50%_50%,transparent_42%,black_95%)] text-foreground"
    >
      <canvas ref={canvas} className="absolute inset-0 size-full" />
    </div>
  )
}

function Stars() {
  return (
    <span className="flex gap-px text-amber-500" aria-label="5 out of 5">
      {Array.from({ length: 5 }, (_, i) => (
        <svg
          key={i}
          viewBox="0 0 20 20"
          aria-hidden="true"
          className="size-2.5"
          fill="currentColor"
        >
          <path d="M10 1.5l2.6 5.3 5.9.9-4.3 4.1 1 5.8L10 14.9l-5.2 2.7 1-5.8L1.5 7.7l5.9-.9L10 1.5z" />
        </svg>
      ))}
    </span>
  )
}

function QuoteCard({
  quote,
  slot,
  index,
  drift,
}: {
  quote: ProofQuote
  slot: string
  index: number
  drift: boolean
}) {
  const still = useReducedMotion() ?? false
  const floating = drift && !still
  return (
    // Cards settle in one after another when the hero comes into view…
    <motion.figure
      className={cn("absolute hidden w-72", slot)}
      initial={{ opacity: 0, y: 14, scale: 0.97 }}
      whileInView={{ opacity: 1, y: 0, scale: 1 }}
      viewport={{ once: true, amount: 0.4 }}
      transition={
        still
          ? { duration: 0 }
          : {
              duration: 0.7,
              delay: 0.15 + index * 0.08,
              ease: [0.2, 0.8, 0.2, 1],
            }
      }
    >
      {/* …then float gently, each on its own rhythm */}
      <motion.div
        className="flex w-full items-start gap-3 rounded-2xl bg-background/75 p-3.5 shadow-[0_20px_50px_-20px_rgba(0,0,0,0.25)] ring-1 ring-foreground/10 backdrop-blur-md dark:shadow-[0_20px_50px_-20px_rgba(0,0,0,0.7)]"
        initial={false}
        animate={floating ? { y: [0, -8, 0] } : { y: 0 }}
        transition={
          floating
            ? {
                duration: 6 + (index % 3) * 1.5,
                ease: "easeInOut",
                repeat: Infinity,
                delay: index * -1.3,
              }
            : { duration: 0.3 }
        }
      >
        {quote.avatar ? (
          // eslint-disable-next-line @next/next/no-img-element
          <img
            src={quote.avatar}
            alt=""
            width={40}
            height={40}
            loading="lazy"
            className="size-10 shrink-0 rounded-full object-cover ring-2 ring-background"
          />
        ) : (
          <span
            aria-hidden="true"
            className="flex size-10 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-semibold text-muted-foreground ring-2 ring-background"
          >
            {initials(quote.name)}
          </span>
        )}
        <div className="min-w-0 text-left">
          <div className="flex items-center gap-2">
            <figcaption className="truncate text-sm font-medium text-foreground">
              {quote.name}
            </figcaption>
            <Stars />
          </div>
          <blockquote className="mt-0.5 line-clamp-2 text-xs leading-relaxed text-muted-foreground">
            {quote.quote}
          </blockquote>
        </div>
      </motion.div>
    </motion.figure>
  )
}

/**
 * A centred hero ringed by short customer quotes that drift at the edges,
 * over a grid of flickering squares that brighten around the cursor and
 * fall quiet behind the title. Cards appear from tablet width up; all text
 * is server-rendered.
 */
export const ProofHero = React.forwardRef<HTMLElement, ProofHeroProps>(
  (
    {
      eyebrow,
      title,
      description,
      quotes = [],
      drift = true,
      flicker = true,
      flickerColor,
      children,
      className,
      onPointerMove,
      onPointerLeave,
      ...props
    },
    ref
  ) => {
    const pointer = React.useRef<{ x: number; y: number } | null>(null)
    return (
      <section
        ref={ref}
        onPointerMove={(e) => {
          const box = e.currentTarget.getBoundingClientRect()
          pointer.current = { x: e.clientX - box.left, y: e.clientY - box.top }
          onPointerMove?.(e)
        }}
        onPointerLeave={(e) => {
          pointer.current = null
          onPointerLeave?.(e)
        }}
        className={cn(
          "relative isolate flex min-h-[600px] w-full items-center justify-center overflow-hidden bg-background px-6 py-24",
          className
        )}
        {...props}
      >
        <div
          aria-hidden="true"
          className="pointer-events-none absolute inset-0 -z-10"
        >
          {flicker && <FlickerGrid color={flickerColor} pointer={pointer} />}
          {/* A soft pool of light under the title */}
          <div className="absolute top-1/2 left-1/2 h-[70%] w-[70%] -translate-1/2 rounded-full bg-[radial-gradient(closest-side,color-mix(in_oklab,currentColor_7%,transparent),transparent)] text-foreground" />
        </div>

        {quotes.slice(0, SLOTS.length).map((quote, i) => (
          <QuoteCard
            key={`${quote.name}-${i}`}
            quote={quote}
            slot={SLOTS[i]}
            index={i}
            drift={drift}
          />
        ))}

        <div className="relative z-10 mx-auto flex max-w-2xl flex-col items-center text-center">
          {eyebrow && (
            <p className="mb-5 rounded-full bg-background/80 px-3 py-1 text-xs font-medium text-muted-foreground ring-1 ring-foreground/10 backdrop-blur">
              {eyebrow}
            </p>
          )}
          <h1 className="text-4xl leading-[1.05] font-semibold tracking-[-0.03em] text-balance text-foreground sm:text-5xl md:text-6xl">
            {title}
          </h1>
          {description && (
            <p className="mt-5 max-w-xl text-base text-pretty text-muted-foreground sm:text-lg">
              {description}
            </p>
          )}
          {children && (
            <div className="mt-8 flex flex-wrap items-center justify-center gap-3">
              {children}
            </div>
          )}
        </div>
      </section>
    )
  }
)
ProofHero.displayName = "ProofHero"

```

**Step 3: Framework Adjustments (Optional)**
If you are manually copying this code into a Vite or Remix project (without using the CLI), make sure to remove the `"use client";` directive from the very top of the file.

## Props
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| `title` | `React.ReactNode` | - | Yes | The main headline. |
| `eyebrow` | `string` | - | No | Small line above the title. |
| `description` | `string` | - | No | Supporting text under the title. |
| `quotes` | `ProofQuote[]` | `[]` | No | Up to six quotes, placed around the edges from the top left. |
| `quotes.name` | `string` | - | Yes | Who said it. |
| `quotes.quote` | `string` | - | Yes | A short quote; long ones are cut to two lines. |
| `quotes.avatar` | `string` | - | No | Photo URL; initials are shown without one. |
| `children` | `React.ReactNode` | - | No | Calls to action or a form, below the description. |
| `drift` | `boolean` | `true` | No | Let the quote cards float gently. |
| `flicker` | `boolean` | `true` | No | Flickering grid of squares behind everything. |
| `flickerColor` | `string` | - | No | Colour of the squares; defaults to the text colour, so it follows the theme. |
| `className` | `string` | - | No | Extra classes for the section. |

## Usage
```tsx
"use client"

import { ProofHero } from "@/components/ui/proof-hero"

const QUOTES = [
  {
    name: "Ana Ribeiro",
    quote: "Our no-shows dropped in the first month.",
    avatar:
      "https://images.unsplash.com/photo-1438761681033-6461ffad8d80?w=200&h=200&fit=crop&crop=faces&q=75",
  },
  {
    name: "Sam Carter",
    quote: "Clients book themselves now. Bliss.",
    avatar:
      "https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=200&h=200&fit=crop&crop=faces&q=75",
  },
  {
    name: "Meera Iyer",
    quote: "Reminders go out without me lifting a finger.",
  },
  {
    name: "John Mathews",
    quote: "Set up in an afternoon, no training needed.",
    avatar:
      "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=400&h=400&fit=crop&q=80",
  },
  {
    name: "Jane Okafor",
    quote: "Our calendar is finally in one place.",
    avatar:
      "https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=400&h=400&fit=crop&q=80",
  },
  {
    name: "Ravi Menon",
    quote: "Payments at booking changed everything.",
    avatar:
      "https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=200&h=200&fit=crop&crop=faces&q=75",
  },
]

export default function ProofHeroDemo() {
  return (
    <ProofHero
      eyebrow="Fieldwork for clinics, salons and studios"
      title="The booking page your customers actually finish"
      description="Fieldwork turns phone calls and DMs into confirmed appointments, with reminders that cut no-shows."
      quotes={QUOTES}
      className="rounded-3xl border bg-background"
    >
      <a
        href="#start"
        className="rounded-full bg-foreground px-5 py-2.5 text-sm font-medium text-background transition-opacity hover:opacity-90"
      >
        Start free
      </a>
      <a
        href="#work"
        className="rounded-full border px-5 py-2.5 text-sm font-medium text-foreground transition-colors hover:bg-muted"
      >
        See a demo
      </a>
    </ProofHero>
  )
}

```
