# Stack Hero
*URL: https://www.grettech.com/components/stack-hero*

A split hero with a checklist on one side and a fanned stack of screenshots on a drifting mesh-gradient stage on the other, framed by design-tool rulers.

- Mesh-gradient stage with drifting colour, grid and grain
- Screenshot stack that fans out on hover and floats gently
- Ruler marks along the frame for a design-tool feel
- Spring fan-out and float with Motion, transforms only

## Install with the shadcn CLI
```bash
npx shadcn@latest add https://www.grettech.com/api/registry/stack-hero
```
With its demo: `npx shadcn@latest add https://www.grettech.com/api/registry/stack-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/stack-hero.tsx`
```tsx
"use client"

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

export type StackImage = { src: string; alt: string }

export interface StackHeroProps extends Omit<
  React.HTMLAttributes<HTMLElement>,
  "title"
> {
  eyebrow?: string
  title: React.ReactNode
  description?: string
  /** Short benefits, shown as a checklist */
  points?: string[]
  /** Calls to action */
  children?: React.ReactNode
  /** Small print under the actions */
  note?: string
  /** Up to three screenshots; the first sits in front */
  images: StackImage[]
  /** Put the screenshots on the left */
  reverse?: boolean
  /** Ruler marks along the edges, like a design tool */
  rulers?: boolean
  /** Three colours for the mesh gradient behind the screenshots */
  colors?: [string, string, string]
}

const GRAIN = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`

/** A slow, endless drift for a mesh blob: there and back again */
const drift = (
  still: boolean,
  to: { x: string; y: string; scale: number },
  from: { scale: number },
  seconds: number
) =>
  still
    ? {}
    : {
        animate: {
          x: ["0%", to.x, "0%"],
          y: ["0%", to.y, "0%"],
          scale: [from.scale, to.scale, from.scale],
        },
        transition: {
          duration: seconds,
          ease: "easeInOut" as const,
          repeat: Infinity,
        },
      }

// Ruler ticks: a short one every 8px and a long one every 40px
const RULER_X: React.CSSProperties = {
  backgroundImage:
    "linear-gradient(to right, currentColor 1px, transparent 1px), linear-gradient(to right, currentColor 1px, transparent 1px)",
  backgroundSize: "8px 5px, 40px 12px",
  backgroundRepeat: "repeat-x",
  backgroundPosition: "left bottom, left bottom",
}
const RULER_Y: React.CSSProperties = {
  backgroundImage:
    "linear-gradient(to bottom, currentColor 1px, transparent 1px), linear-gradient(to bottom, currentColor 1px, transparent 1px)",
  backgroundSize: "5px 8px, 12px 40px",
  backgroundRepeat: "repeat-y",
  backgroundPosition: "right top, right top",
}

// Front, middle and back card: at rest, and fanned out on hover
const CARDS: { z: string; variants: Variants }[] = [
  {
    z: "z-30",
    variants: {
      rest: { x: "0%", y: "0%", rotate: -2, scale: 1 },
      fan: { x: "0%", y: "-4%", rotate: 0, scale: 1.03 },
    },
  },
  {
    z: "z-20",
    variants: {
      rest: { x: "16%", y: "-16%", rotate: 6, scale: 1 },
      fan: { x: "24%", y: "-22%", rotate: 10, scale: 1 },
    },
  },
  {
    z: "z-10",
    variants: {
      rest: { x: "-16%", y: "-26%", rotate: -9, scale: 1 },
      fan: { x: "-24%", y: "-32%", rotate: -14, scale: 1 },
    },
  },
]

function Check() {
  return (
    <svg
      viewBox="0 0 16 16"
      aria-hidden="true"
      className="size-3"
      fill="none"
      stroke="currentColor"
      strokeWidth="2.5"
    >
      <path d="M3.5 8.5l3 3 6-7" strokeLinecap="round" strokeLinejoin="round" />
    </svg>
  )
}

/**
 * A split hero: copy and a checklist on one side, and on the other a stack
 * of three screenshots that fans out on hover and floats gently. Ruler
 * marks along the frame give it a design-tool feel. Motion drives the float,
 * the drifting mesh and the spring fan-out, with transforms only; reduced
 * motion holds it still.
 */
export const StackHero = React.forwardRef<HTMLElement, StackHeroProps>(
  (
    {
      eyebrow,
      title,
      description,
      points = [],
      children,
      note,
      images,
      reverse = false,
      rulers = true,
      colors = ["#38bdf8", "#a78bfa", "#f472b6"],
      className,
      ...props
    },
    ref
  ) => {
    const still = useReducedMotion() ?? false
    return (
      <section
        ref={ref}
        className={cn("w-full px-4 py-10 sm:px-6 sm:py-14", className)}
        {...props}
      >
        <div className="relative mx-auto max-w-6xl">
          {rulers && (
            <div
              aria-hidden="true"
              className="pointer-events-none absolute inset-0 text-foreground/15"
            >
              <div
                className="absolute inset-x-0 top-0 h-3 border-b border-current"
                style={RULER_X}
              />
              <div
                className="absolute inset-y-0 left-0 w-3 border-r border-current"
                style={RULER_Y}
              />
              <div className="absolute inset-x-0 bottom-0 h-px bg-current" />
              <div className="absolute inset-y-0 right-0 w-px bg-current" />
            </div>
          )}

          <div
            className={cn(
              "grid items-center gap-14 px-6 py-16 sm:px-12 lg:grid-cols-2 lg:gap-10 lg:py-20",
              reverse && "lg:[&>*:first-child]:order-2"
            )}
          >
            <div>
              {eyebrow && (
                <p className="mb-5 inline-flex items-center gap-2 rounded-full border px-3 py-1 text-xs font-medium text-muted-foreground">
                  <span className="size-1.5 rounded-full bg-emerald-500" />
                  {eyebrow}
                </p>
              )}
              <h1 className="text-4xl leading-[1.05] font-semibold tracking-tight text-balance text-foreground sm:text-5xl lg:text-6xl">
                {title}
              </h1>
              {description && (
                <p className="mt-5 max-w-lg text-base text-pretty text-muted-foreground sm:text-lg">
                  {description}
                </p>
              )}
              {points.length > 0 && (
                <ul className="mt-7 space-y-3">
                  {points.map((point, i) => (
                    <li
                      key={`${point}-${i}`}
                      className="flex items-start gap-3 text-sm text-foreground sm:text-base"
                    >
                      <span className="mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full bg-foreground text-background">
                        <Check />
                      </span>
                      {point}
                    </li>
                  ))}
                </ul>
              )}
              {children && (
                <div className="mt-8 flex flex-wrap items-center gap-3">
                  {children}
                </div>
              )}
              {note && (
                <p className="mt-4 text-xs text-muted-foreground">{note}</p>
              )}
            </div>

            <motion.div
              className="relative mx-auto w-full max-w-xl"
              initial="rest"
              animate="rest"
              whileHover="fan"
            >
              {/* Mesh gradient panel: three drifting colour fields, a faint
              grid and grain, so the screenshots sit on a stage */}
              <div
                aria-hidden="true"
                className="absolute -inset-x-3 -inset-y-10 overflow-hidden rounded-[32px] bg-muted ring-1 ring-foreground/10 sm:-inset-x-6"
              >
                <motion.div
                  className="absolute -top-1/4 -left-1/4 size-[85%] rounded-full opacity-80 blur-3xl dark:opacity-60"
                  style={{
                    backgroundImage: `radial-gradient(closest-side, ${colors[0]}, transparent)`,
                  }}
                  {...drift(
                    still,
                    { x: "12%", y: "10%", scale: 1.15 },
                    { scale: 1 },
                    16
                  )}
                />
                <motion.div
                  className="absolute -right-1/4 -bottom-1/4 size-[90%] rounded-full opacity-80 blur-3xl dark:opacity-60"
                  style={{
                    backgroundImage: `radial-gradient(closest-side, ${colors[1]}, transparent)`,
                  }}
                  {...drift(
                    still,
                    { x: "-14%", y: "-8%", scale: 0.95 },
                    { scale: 1.1 },
                    19
                  )}
                />
                <motion.div
                  className="absolute top-1/3 left-1/4 size-[60%] rounded-full opacity-70 blur-3xl dark:opacity-50"
                  style={{
                    backgroundImage: `radial-gradient(closest-side, ${colors[2]}, transparent)`,
                  }}
                  {...drift(
                    still,
                    { x: "12%", y: "10%", scale: 1.15 },
                    { scale: 1 },
                    23
                  )}
                />
                <div className="absolute inset-0 [background-image:linear-gradient(to_right,color-mix(in_oklab,currentColor_8%,transparent)_1px,transparent_1px),linear-gradient(to_bottom,color-mix(in_oklab,currentColor_8%,transparent)_1px,transparent_1px)] [mask-image:radial-gradient(ellipse_at_center,black,transparent_80%)] [background-size:40px_40px] text-foreground" />
                <div
                  className="absolute inset-0 opacity-30 mix-blend-overlay"
                  style={{ backgroundImage: GRAIN }}
                />
              </div>
              {/* The stack floats gently; it fans out on hover */}
              <motion.div
                className="relative mx-auto aspect-[5/4] w-full"
                {...(!still && {
                  animate: { y: [0, -10, 0] },
                  transition: {
                    duration: 7,
                    ease: "easeInOut",
                    repeat: Infinity,
                  },
                })}
              >
                {images
                  .filter((image) => image.src)
                  .slice(0, 3)
                  .map((image, i) => (
                    <motion.figure
                      key={`${image.src}-${i}`}
                      className={cn(
                        "absolute inset-x-[15%] top-[32%] rounded-xl border bg-background p-1.5 shadow-[0_24px_60px_-20px_rgba(0,0,0,0.35)]",
                        CARDS[i].z
                      )}
                      variants={CARDS[i].variants}
                      transition={{
                        type: "spring",
                        stiffness: 160,
                        damping: 20,
                      }}
                    >
                      <div
                        aria-hidden="true"
                        className="flex gap-1 px-1.5 pt-0.5 pb-1.5"
                      >
                        <span className="size-1.5 rounded-full bg-muted-foreground/30" />
                        <span className="size-1.5 rounded-full bg-muted-foreground/30" />
                        <span className="size-1.5 rounded-full bg-muted-foreground/30" />
                      </div>
                      {/* eslint-disable-next-line @next/next/no-img-element */}
                      <img
                        src={image.src}
                        alt={image.alt}
                        loading={i === 0 ? "eager" : "lazy"}
                        className="aspect-[16/10] w-full rounded-lg object-cover object-top"
                      />
                    </motion.figure>
                  ))}
              </motion.div>
            </motion.div>
          </div>
        </div>
      </section>
    )
  }
)
StackHero.displayName = "StackHero"

```

**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. Wrap part of it in a muted span for a two-tone title. |
| `images` | `StackImage[]` | - | Yes | Up to three screenshots; the first sits in front. |
| `images.src` | `string` | - | Yes | Image URL. |
| `images.alt` | `string` | - | Yes | Description of the image. |
| `eyebrow` | `string` | - | No | Small label above the title. |
| `description` | `string` | - | No | Supporting text under the title. |
| `points` | `string[]` | `[]` | No | Short benefits, shown as a checklist. |
| `children` | `React.ReactNode` | - | No | Calls to action. |
| `note` | `string` | - | No | Small print under the actions. |
| `reverse` | `boolean` | `false` | No | Put the screenshots on the left. |
| `rulers` | `boolean` | `true` | No | Ruler marks along the edges. |
| `colors` | `[string, string, string]` | `["#38bdf8", "#a78bfa", "#f472b6"]` | No | Three colours for the mesh gradient behind the screenshots. |
| `className` | `string` | - | No | Extra classes for the section. |

## Usage
```tsx
"use client"

import { StackHero } from "@/components/ui/stack-hero"

export default function StackHeroDemo() {
  return (
    <StackHero
      eyebrow="Pagewright for studios"
      title={
        <>
          Launch client sites faster.{" "}
          <span className="text-muted-foreground">Skip the late nights.</span>
        </>
      }
      description="Build from sections your clients can edit themselves, then publish with hosting, forms and analytics already set up."
      points={[
        "Page sections your clients can edit safely",
        "One review link for feedback and approvals",
        "Hosting, forms and analytics included",
      ]}
      note="Free while you build. Pay when a site goes live."
      images={[
        {
          src:
            "https://images.unsplash.com/photo-1551288049-bebda4e38f71?w=800&q=75&auto=format",
          alt: "Analytics dashboard for a client site",
        },
        {
          src:
            "https://images.unsplash.com/photo-1460925895917-afdab827c52f?q=75&w=1200&auto=format&fit=crop",
          alt: "Traffic report open on a laptop",
        },
        {
          src:
            "https://images.unsplash.com/photo-1498050108023-c5249f4df085?q=75&w=1200&auto=format&fit=crop",
          alt: "Site code open in an editor",
        },
      ]}
      className="rounded-3xl border bg-background"
    >
      <a
        href="#start"
        className="rounded-lg bg-foreground px-5 py-2.5 text-sm font-medium text-background transition-opacity hover:opacity-90"
      >
        Start building
      </a>
      <a
        href="#examples"
        className="rounded-lg border px-5 py-2.5 text-sm font-medium text-foreground transition-colors hover:bg-muted"
      >
        See examples
      </a>
    </StackHero>
  )
}

```
