---
title: Section 3D
description: Tall cards that fall back into 3D as the next one arrives.
category: Scroll
tier: free
url: https://ui.dimaac.com/components/section-3d
registry: https://ui.dimaac.com/r/section-3d.json
---

# Section 3D

A scroll section for a team or an our-work list. The page pins one stage; as you scroll, the next tall photo card rises from the bottom while the card under it fades, lifts and tips back into the screen. One pin and one scrubbed timeline run the whole stack, so a dozen cards stay light, and the animation plays backwards when you scroll up. Tilt, depth, lift, fade, perspective and how much scrolling each hand-over takes are all props. It works on the page or inside any scrolling element through the scroller prop, re-measures when the window or the scroller changes size, uses plain img tags (no Next.js needed) and turns into an ordinary tall page of cards when the visitor prefers reduced motion. Ported from the first DiMaac UI, where every card was pinned on its own.

## Install

With the shadcn CLI:

```bash
npx shadcn@latest add https://ui.dimaac.com/r/section-3d.json
pnpm dlx shadcn@latest add https://ui.dimaac.com/r/section-3d.json
bunx --bun shadcn@latest add https://ui.dimaac.com/r/section-3d.json
```

With the `@dimaac` namespace in components.json: `npx shadcn@latest add @dimaac/section-3d`

Dependencies:

```bash
pnpm add gsap @gsap/react
npm install gsap @gsap/react
```

By hand:

1. Install the packages it uses: gsap, @gsap/react.
2. Copy the component file below into components/dimaac/section-3d.tsx.
3. It's styled with Tailwind v4 classes. If that folder sits outside the places Tailwind scans, add it with @source in your CSS.
4. Import it with import { Section3d } from "@/components/dimaac/section-3d". Give its parent a size: it fills it.

## Usage

```tsx
import { Section3d } from "@/components/dimaac/section-3d";

<Section3d />
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |

## Credits

- Portrait (Marcus Chen): studiomiklus, Lummi (https://www.lummi.ai/photo/striking-portrait-jodiu), Lummi License
- Portrait (Elena Voss): Edita, Lummi (https://www.lummi.ai/photo/striking-portrait-kfent), Lummi License
- Portrait (Priya Nair): Shaun Duval, Lummi (https://www.lummi.ai/photo/portrait-with-neon-sunglasses-gindg), Lummi License
- Portrait (Sofia Reyes): SHIHO, Lummi (https://www.lummi.ai/photo/vibrant-woman-portrait-htofy), Lummi License
- Portrait (Ava Mitchell): Amino, Lummi (https://www.lummi.ai/photo/vivid-portrait-on-pink-oxbow), Lummi License
- Portrait (Kai Tanaka): Steph Meade, Lummi (https://www.lummi.ai/photo/expressive-minimal-portrait-jrfyc), Lummi License
- Portrait (Liam Foster): Lloyd Creates, Lummi (https://www.lummi.ai/photo/poised-portrait-ooi9b), Lummi License
- Portrait (Nina Patel): Amino, Lummi (https://www.lummi.ai/photo/stylish-portrait-8inth), Lummi License

## Source

### section-3d.tsx → `components/dimaac/section-3d.tsx`

```tsx
"use client";

import { useEffect, useRef, type CSSProperties } from "react";
import { gsap } from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
import { useGSAP } from "@gsap/react";

// A stack of tall photo cards that arrive one after another. The page pins a single stage; as you
// scroll, the next card rises from the bottom while the card under it fades, lifts and tips back
// into the screen, as if it were falling away into a room behind the page.
// One pin and one scrubbed timeline run the whole thing (the first version pinned every card on its
// own, which got heavy with a dozen cards). The animation is tied to the scrollbar, so it also
// plays backwards when you scroll up.

if (typeof window !== "undefined") gsap.registerPlugin(useGSAP, ScrollTrigger);

export type Section3DCard = {
  /** The photo. */
  image: string;
  /** Alt text for the photo. Falls back to the name. */
  imageAlt?: string;
  /** A small label above the name, e.g. "01 / 08". */
  number: string;
  /** The big line on the card. */
  name: string;
  /** The line under the name. */
  role: string;
  /** A short quote at the bottom of the card. Leave it out for no quote. */
  quote?: string;
};

export type Section3DProps = {
  /** The cards, in the order they arrive. */
  cards: Section3DCard[];
  /** The big heading of the opening screen. */
  introTitle?: string;
  /** The paragraph under it. Pass an empty string to leave it out. */
  introDescription?: string;
  /** How far a card tips back while the next one arrives, in degrees. */
  tilt?: number;
  /** How far a card sinks away from you, in pixels. */
  depth?: number;
  /** How far a card rises while it recedes, as a percentage of its own height. */
  lift?: number;
  /** How much a receding card fades out, from 0 (stays solid) to 1 (fully gone). */
  fade?: number;
  /** Depth of the 3D effect, in pixels. Smaller is more dramatic. */
  perspective?: number;
  /** How much scrolling one hand-over takes, in screens. 1 moves the next card exactly with your scroll. */
  scrollPerCard?: number;
  /** The start colour of the heading underline and the small line on each card. */
  accent?: string;
  /** The end colour of those two gradients. */
  accentEnd?: string;
  /** The colour behind the cards. Use a dark one: the text on the page is light. */
  backdrop?: string;
  /** The scrolling element. Leave it out to use the page; give it a selector or an element for an inner scroller. */
  scroller?: string | HTMLElement;
  /** Extra classes for the outer wrapper. */
  className?: string;
};

export function Section3D({
  cards,
  introTitle = "Portraits",
  introDescription = "Eight photos in one stack. Scroll to bring the next one up.",
  tilt = 80,
  depth = 800,
  lift = 25,
  fade = 1,
  perspective = 1000,
  scrollPerCard = 1,
  accent = "#ff6b35",
  accentEnd = "#f7c59f",
  backdrop = "#160f03",
  scroller,
  className = "",
}: Section3DProps) {
  const rootRef = useRef<HTMLDivElement>(null);
  const cardCount = cards.length;
  // The motion settings are read by the tweens when they (re)measure, so dragging a slider in a
  // playground doesn't rebuild the pin and throw the visitor back up the page
  const settings = useRef({ tilt, depth, lift, fade, scrollPerCard });
  settings.current = { tilt, depth, lift, fade, scrollPerCard };
  const trigger = useRef<ScrollTrigger | null>(null);

  useGSAP(
    () => {
      const root = rootRef.current;
      if (!root || cardCount === 0) return;

      const mm = gsap.matchMedia();

      // Reduced motion: nothing is pinned or tipped. The cards are just a tall page, one after another.
      mm.add("(prefers-reduced-motion: no-preference)", () => {
        const stage = root.querySelector<HTMLElement>("[data-s3d-stage]");
        const slots = gsap.utils.toArray<HTMLElement>("[data-s3d-slot]", root);
        const faces = gsap.utils.toArray<HTMLElement>("[data-s3d-card]", root);
        const line = root.querySelector<HTMLElement>("[data-s3d-line]");
        if (!stage) return;

        // Inside an inner scroller, "a screen" means that scroller's height, not the window's
        const scrollEl = typeof scroller === "string" ? document.querySelector<HTMLElement>(scroller) : scroller;
        const syncHeight = (): void => {
          root.style.setProperty("--s3d-h", scrollEl ? `${scrollEl.clientHeight}px` : "100svh");
        };
        syncHeight();
        ScrollTrigger.addEventListener("refreshInit", syncHeight);

        // The slow light that runs down the line at the bottom of the opening screen
        if (line) gsap.fromTo(line, { yPercent: -100 }, { yPercent: 100, duration: 2, ease: "sine.inOut", repeat: -1 });

        // One timeline, one step per hand-over: card i+1 rises into view while card i falls back.
        // Every step is one unit long and the steps run back to back, so scrub keeps them in order.
        if (cardCount > 1) {
          const handOvers = gsap.timeline({
            defaults: { ease: "none", duration: 1 },
            scrollTrigger: {
              trigger: stage,
              scroller,
              start: "top top",
              // Measured on every refresh, so rotating a phone or resizing the window stays correct
              end: () => `+=${(cardCount - 1) * stage.offsetHeight * settings.current.scrollPerCard}`,
              pin: true,
              scrub: true,
              anticipatePin: 1,
              invalidateOnRefresh: true,
            },
          });

          trigger.current = handOvers.scrollTrigger ?? null;

          for (let i = 1; i < cardCount; i++) {
            // The new card starts just below the stage (its slot sits at top: 100%) and climbs to the top
            handOvers.fromTo(slots[i]!, { yPercent: 0 }, { yPercent: -100 }, i - 1);
            handOvers.fromTo(
              faces[i - 1]!,
              { opacity: 1, yPercent: 0, z: 0, rotationX: 0 },
              {
                opacity: () => 1 - settings.current.fade,
                yPercent: () => -settings.current.lift,
                z: () => -settings.current.depth,
                rotationX: () => settings.current.tilt,
                transformOrigin: "50% 50%",
                force3D: true,
              },
              i - 1,
            );
          }
        }

        // A scroller that changes size (a resizable panel, for example) needs the pin measured again
        let measure: gsap.core.Tween | undefined;
        const observer = scrollEl ? new ResizeObserver(() => {
          measure?.kill();
          measure = gsap.delayedCall(0.2, () => ScrollTrigger.refresh());
        }) : null;
        if (scrollEl) observer?.observe(scrollEl);

        return () => {
          measure?.kill();
          observer?.disconnect();
          ScrollTrigger.removeEventListener("refreshInit", syncHeight);
          trigger.current = null;
          root.style.removeProperty("--s3d-h");
        };
      });

      return () => mm.revert();
    },
    { scope: rootRef, dependencies: [cardCount, scroller], revertOnUpdate: true },
  );

  // New motion settings: measure the pin again, keeping the scroll position
  useEffect(() => {
    trigger.current?.refresh();
  }, [tilt, depth, lift, fade, scrollPerCard]);

  const style = { backgroundColor: backdrop, "--s3d-h": "100svh" } as CSSProperties;
  const gradient = `linear-gradient(90deg, ${accent}, ${accentEnd})`;

  return (
    <div ref={rootRef} className={`relative w-full overflow-x-clip text-white ${className}`} style={style}>
      {/* The opening screen. It scrolls like a normal page. */}
      <section className="flex h-[var(--s3d-h)] flex-col items-center justify-center px-6 text-center md:px-8">
        <h2
          className="mt-auto mb-6 bg-clip-text text-[clamp(48px,8vw,80px)] leading-[1.05] font-extrabold tracking-[-0.02em] text-transparent"
          style={{ backgroundImage: `linear-gradient(135deg, ${accent} 0%, ${accentEnd} 50%, #fff 100%)` }}
        >
          {introTitle}
        </h2>
        {introDescription ? <p className="max-w-[500px] px-4 text-[clamp(16px,1.4vw,18px)] leading-normal tracking-[0.02em] text-white/50">{introDescription}</p> : null}
        <div aria-hidden="true" className="relative mt-auto h-24 w-px overflow-hidden bg-white/10 md:h-48">
          <span data-s3d-line className="absolute inset-0 block bg-gradient-to-b from-transparent via-white/60 to-transparent" />
        </div>
      </section>

      {/* The stage that gets pinned. The cards sit stacked inside it. */}
      <ul data-s3d-stage className="relative m-0 block h-[var(--s3d-h)] list-none overflow-hidden p-0 motion-reduce:h-auto motion-reduce:overflow-visible">
        {cards.map((card, index) => (
          <li
            key={`${index}-${card.image}`}
            data-s3d-slot
            // The first card fills the stage; the others wait just below it. Reduced motion stacks them in the flow.
            className={`absolute left-0 flex h-[var(--s3d-h)] w-full items-center justify-center p-4 md:p-8 motion-reduce:static motion-reduce:py-10 ${index === 0 ? "top-0" : "top-full"}`}
            style={{ perspective, transformStyle: "preserve-3d" }}
          >
            <article
              data-s3d-card
              className="relative h-[80%] w-[92%] max-w-[500px] overflow-hidden rounded-2xl bg-black/40 md:w-1/2 md:max-w-[360px] md:min-w-[280px] md:rounded-[2rem] lg:w-[35%] lg:max-w-[500px] lg:min-w-[380px]"
              style={{ willChange: "transform, opacity" }}
            >
              <img
                src={card.image}
                alt={card.imageAlt ?? card.name}
                className="absolute inset-0 h-full w-full object-cover"
                loading={index < 2 ? "eager" : "lazy"}
                decoding="async"
                draggable={false}
              />
              <div className="absolute inset-0 flex flex-col justify-end bg-gradient-to-t from-black/90 via-black/40 via-30% to-transparent to-60% p-6 md:p-10">
                <span className="mb-3 block text-[11px] font-semibold tracking-[0.3em] text-white/50 uppercase">{card.number}</span>
                <h3 className="mb-2 text-[clamp(22px,2.2vw,32px)] leading-[1.1] font-extrabold tracking-[-0.02em] text-white">{card.name}</h3>
                <p className="text-sm font-medium tracking-[0.05em] text-white/70 md:text-[15px]">{card.role}</p>
                <div className="mt-4 h-[3px] w-10 rounded-full" style={{ backgroundImage: gradient }} />
                {card.quote ? <p className="mt-4 text-xs leading-normal text-white/50 italic md:text-[13px]">&ldquo;{card.quote}&rdquo;</p> : null}
              </div>
            </article>
          </li>
        ))}
      </ul>
    </div>
  );
}
```

### demo.tsx (the demo on the page, not installed)

```tsx
"use client";

import { Section3D, type Section3DCard, type Section3DProps } from "@/components/dimaac/section-3d";

// Eight portraits in a stack. They are Lummi photos (Lummi License: free for personal and commercial use).
// The page behind the cards is always dark, so the effect reads the same in the light and the dark site theme.

const portraits: Section3DCard[] = [
  {
    image: "https://ui.dimaac.com/media/portraits/platinum-blonde-4x5.jpg",
    imageAlt: "Close-up of a young man with platinum blonde hair, green eyes, and a yellow jacket against a bold orange background",
    number: "No. 01 / 08",
    name: "Platinum",
    role: "Yellow jacket, orange wall",
  },
  {
    image: "https://ui.dimaac.com/media/portraits/glossy-lowkey-4x5.jpg",
    imageAlt: "Close-up portrait of a woman with glossy lips, sparkling earrings, and dramatic lighting highlighting her features and purple attire",
    number: "No. 02 / 08",
    name: "Glossy",
    role: "Low light, purple silk",
  },
  {
    image: "https://ui.dimaac.com/media/portraits/neon-profile-4x5.jpg",
    imageAlt: "A bold profile shot of a woman in neon pink sunglasses against a vibrant blue background, showcasing a modern and artistic vibe",
    number: "No. 03 / 08",
    name: "Neon pink",
    role: "Sunglasses on blue",
  },
  {
    image: "https://ui.dimaac.com/media/portraits/tinted-glasses-4x5.jpg",
    imageAlt: "Stylish woman in purple-tinted sunglasses, braided hair, and a vibrant shirt against a glowing orange-yellow background",
    number: "No. 04 / 08",
    name: "Tinted glasses",
    role: "Braids against amber",
  },
  {
    image: "https://ui.dimaac.com/media/portraits/lime-blazer-4x5.jpg",
    imageAlt: "A person with curly red hair wearing a lime green blazer with a blue lapel stands against a bright pink background",
    number: "No. 05 / 08",
    name: "Lime blazer",
    role: "Red curls, pink wall",
  },
  {
    image: "https://ui.dimaac.com/media/portraits/light-streaks-4x5.jpg",
    imageAlt: "Close-up of a face with blue eyes and colourful streaks of light",
    number: "No. 06 / 08",
    name: "Light streaks",
    role: "Blue eyes, coloured light",
  },
  {
    image: "https://ui.dimaac.com/media/portraits/red-coat-4x5.jpg",
    imageAlt: "A striking portrait of a person in a red coat against a deep blue background, showcasing bold contrasts and captivating lighting",
    number: "No. 07 / 08",
    name: "Red coat",
    role: "Deep blue backdrop",
  },
  {
    image: "https://ui.dimaac.com/media/portraits/burgundy-blazer-4x5.jpg",
    imageAlt: "A stylish individual in a burgundy blazer and white turtleneck, set against a neutral background, showcasing elegance and sophistication",
    number: "No. 08 / 08",
    name: "Burgundy blazer",
    role: "White turtleneck",
  },
];

export default function Demo(props: Partial<Section3DProps>) {
  return (
    <div className="w-full font-[family-name:Syne,sans-serif]">
      <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&display=swap" precedence="default" />
      <Section3D cards={portraits} {...props} />
    </div>
  );
}
```

## Agent prompt

```text
Add the Section 3D component (<Section3d />) from DiMaac UI to this project.

Docs: https://ui.dimaac.com/components/section-3d
Source and dependencies (shadcn registry JSON): https://ui.dimaac.com/r/section-3d.json

Install it with:
npx shadcn@latest add https://ui.dimaac.com/r/section-3d.json

Then use it like this:
import { Section3d } from "@/components/dimaac/section-3d";
<Section3d />

If the shadcn CLI isn't set up here, fetch the registry JSON above, write files[0].content to components/dimaac/section-3d.tsx and install gsap, @gsap/react.
It uses Tailwind v4 classes, so make sure Tailwind scans that folder. Give its parent a size: it fills it. Keep light and dark mode working and keep its prefers-reduced-motion fallback.
Full index for agents: https://ui.dimaac.com/llms.txt
```
