---
title: Pin rotate sections
description: Pinned sections that turn in 3D.
category: Scroll
tier: free
url: https://ui.dimaac.com/components/pin-rotate-sections
registry: https://ui.dimaac.com/r/pin-rotate-sections.json
---

# Pin rotate sections

A stack of full-screen sections. Each one pins to the top of the page, and while the next section slides up over it the pinned one shrinks, tips back in 3D, turns a few degrees and fades to dark, like a deck of cards being pushed away. The tilt alternates left and right from card to card. The animation is scrubbed to the scrollbar, so it runs back when you scroll up. It works on the page or inside any scrolling element through the scroller prop, handles cards taller than the screen on phones, measures again when pictures load, and falls back to an ordinary page with every section visible when the visitor prefers reduced motion. Four small parts: PinRotateSections, PinRotateIntro, PinRotateSection and PinRotateOutro.

## Install

With the shadcn CLI:

```bash
npx shadcn@latest add https://ui.dimaac.com/r/pin-rotate-sections.json
pnpm dlx shadcn@latest add https://ui.dimaac.com/r/pin-rotate-sections.json
bunx --bun shadcn@latest add https://ui.dimaac.com/r/pin-rotate-sections.json
```

With the `@dimaac` namespace in components.json: `npx shadcn@latest add @dimaac/pin-rotate-sections`

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/pin-rotate-sections.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 { PinRotateSections } from "@/components/dimaac/pin-rotate-sections". Give its parent a size: it fills it.

## Usage

```tsx
import { PinRotateSections } from "@/components/dimaac/pin-rotate-sections";

<PinRotateSections children={children} />
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` (required) | `ReactNode` | - | The intro, the sections and the outro, in order. Sections are found by <PinRotateSection>. |
| `shrink` | `number` | `0.25` | How much each section shrinks while it is pushed away. 0.25 ends at 75% of its size. |
| `tilt` | `number` | `40` | How far each section tips back, in degrees. The direction alternates from card to card. |
| `twist` | `number` | `5` | How far each section turns in the page plane, in degrees. Also alternates. |
| `dim` | `number` | `0.4` | How dark a pushed-away section gets, from 0 (not at all) to 1 (black). |
| `perspective` | `number` | `2200` | Depth of the tilt, in pixels. Smaller is more dramatic. Below about 800 the corners can glitch. |
| `backdrop` | `string` | `"#1a1a1a"` | The colour that shows behind and around the shrinking sections. |
| `scroller` | `string \| HTMLElement` | - | The scrolling element. Leave it out to use the page; give it a selector or an element for an inner scroller. |
| `className` | `string` | `""` | Extra classes for the outer wrapper. |

## Credits

- Concrete Corner: Ricardo Matos, Lummi (https://www.lummi.ai/photo/minimalist-urban-design-abiri), Lummi License
- Balcony Study: Mariate, Lummi (https://www.lummi.ai/photo/minimalist-architectural-design-b8bbc), Lummi License
- The Red Wall: Siren Media, Lummi (https://www.lummi.ai/photo/modern-interior-with-red-wall-6k-hl), Lummi License
- White Corner: Mikiwa, Lummi (https://www.lummi.ai/photo/modern-building-corner-dr5dz), Lummi License
- Palm Court: Binks AI, Lummi (https://www.lummi.ai/photo/serene-minimalist-scene-with-palm-trees-pba-c), Lummi License

## Source

### pin-rotate-sections.tsx → `components/dimaac/pin-rotate-sections.tsx`

```tsx
"use client";

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

// Full-screen sections that stack like a deck of cards. Each one pins to the top of the page, and
// while the next section slides up over it, the pinned one shrinks, tilts back and fades to dark,
// as if it were being pushed away. Four small pieces:
//   <PinRotateSections>  wraps everything and runs the animation
//   <PinRotateIntro> and <PinRotateOutro>  the plain dark openers and closers
//   <PinRotateSection>  one card in the stack. The animated ones are the sections.

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

export type PinRotateSectionsProps = {
  /** The intro, the sections and the outro, in order. Sections are found by <PinRotateSection>. */
  children: ReactNode;
  /** How much each section shrinks while it is pushed away. 0.25 ends at 75% of its size. */
  shrink?: number;
  /** How far each section tips back, in degrees. The direction alternates from card to card. */
  tilt?: number;
  /** How far each section turns in the page plane, in degrees. Also alternates. */
  twist?: number;
  /** How dark a pushed-away section gets, from 0 (not at all) to 1 (black). */
  dim?: number;
  /** Depth of the tilt, in pixels. Smaller is more dramatic. Below about 800 the corners can glitch. */
  perspective?: number;
  /** The colour that shows behind and around the shrinking sections. */
  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 PinRotateSections({
  children,
  shrink = 0.25,
  tilt = 40,
  twist = 5,
  dim = 0.4,
  perspective = 2200,
  backdrop = "#1a1a1a",
  scroller,
  className = "",
}: PinRotateSectionsProps) {
  const rootRef = useRef<HTMLDivElement>(null);
  // The effect has to start again when sections are added or removed
  const childCount = Children.count(children);

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

      const mm = gsap.matchMedia();

      // Reduced motion: no pinning and no tilting. The sections are just a normal page.
      mm.add("(prefers-reduced-motion: no-preference)", () => {
        const sections = gsap.utils.toArray<HTMLElement>("[data-pin-rotate-section]", root);
        const last = sections[sections.length - 1];
        if (!last) return;

        // The scroller can be a selector or an element: find the element once. A selector must be looked up
        // here, outside the scope, because the scope only searches inside this wrapper and the scroller is
        // always outside it. Using the element also lets us measure the scroller's height, not the window's.
        const scrollEl = (typeof scroller === "string" ? document.querySelector<HTMLElement>(scroller) : scroller) ?? undefined;
        // The height we measure sections against: the scroller's, or the window's
        const viewHeight = () => (scrollEl ? scrollEl.clientHeight : window.innerHeight);

        sections.forEach((section, index) => {
          const next = sections[index + 1];
          // The last card doesn't move: it is the one everything is pushed away by
          if (!next) return;

          const direction = index % 2 === 0 ? 1 : -1;
          const overlay = section.querySelector<HTMLElement>("[data-pin-rotate-overlay]");

          // Pin the card until the last one arrives, so the next card slides over the top of it.
          // A card taller than the screen (common on phones) pins by its bottom edge instead,
          // so its whole content gets read before it is covered.
          ScrollTrigger.create({
            trigger: section,
            scroller: scrollEl,
            start: () => (section.offsetHeight > viewHeight() ? "bottom bottom" : "top top"),
            endTrigger: last,
            end: "top top",
            pin: true,
            pinSpacing: false,
          });

          // While the next card climbs from the bottom edge to the top, the pinned card is pushed away.
          // scrub ties the animation to the scrollbar, so it runs back when you scroll up.
          const away = gsap.timeline({
            defaults: { ease: "none" },
            scrollTrigger: { trigger: next, scroller: scrollEl, start: "top bottom", end: "top top", scrub: true },
          });
          away.to(section, { scale: 1 - shrink, rotation: direction * twist, rotationX: direction * tilt, transformPerspective: perspective || 0, force3D: true }, 0);
          if (overlay) away.to(overlay, { opacity: dim }, 0);
        });

        // Pictures arriving late change the page height, so measure the pins again.
        // A short delay turns a burst of loads into one measurement.
        let measure: gsap.core.Tween | undefined;
        const observer = new ResizeObserver(() => {
          measure?.kill();
          measure = gsap.delayedCall(0.2, () => ScrollTrigger.refresh());
        });
        // Only the wrapper: a pinned card changes its own box while it sticks, which must not re-trigger this
        observer.observe(root);

        return () => {
          measure?.kill();
          observer.disconnect();
        };
      });

      return () => mm.revert();
    },
    { scope: rootRef, dependencies: [childCount, shrink, tilt, twist, dim, perspective, scroller], revertOnUpdate: true },
  );

  return (
    <div ref={rootRef} className={`relative w-full overflow-x-clip ${className}`} style={{ backgroundColor: backdrop }}>
      {children}
    </div>
  );
}

export type PinRotateIntroProps = {
  /** The opening words: usually a heading and a paragraph. */
  children: ReactNode;
  /** Extra classes: change the colours, the height or the padding here. */
  className?: string;
};

/** A full-height dark opener. It scrolls normally. */
export function PinRotateIntro({ children, className = "" }: PinRotateIntroProps) {
  return (
    <section data-pin-rotate-intro className={`flex min-h-[100svh] flex-col items-center justify-center bg-[#1a1a1a] px-[6vw] text-center text-white md:px-[8vw] ${className}`}>
      {children}
    </section>
  );
}

export type PinRotateSectionProps = {
  /** What the card shows. */
  children: ReactNode;
  /** Extra classes: the background, text colour and padding. Cards are paper-coloured by default. */
  className?: string;
  /** Inline styles for the card, e.g. a background image. */
  style?: CSSProperties;
};

/** One card of the stack. It pins, then shrinks and darkens as the next card covers it. */
export function PinRotateSection({ children, className = "", style }: PinRotateSectionProps) {
  return (
    <section
      data-pin-rotate-section
      className={`relative flex min-h-[85svh] flex-col bg-[#fcfcfc] px-[6vw] py-[5vh] text-[#1a1a1a] md:flex-row md:justify-between md:px-[8vw] md:py-[10vh] ${className}`}
      style={{ borderBottom: "1px solid rgba(0,0,0,0.24)", willChange: "transform", transformStyle: "flat", ...style }}
    >
      {children}
      {/* The shadow that grows over the card as it is pushed away */}
      <div data-pin-rotate-overlay aria-hidden="true" className="pointer-events-none absolute inset-0 bg-black opacity-0 [backface-visibility:hidden]" />
    </section>
  );
}

export type PinRotateOutroProps = {
  /** The closing words. */
  children: ReactNode;
  /** Extra classes: change the colours, the height or the padding here. */
  className?: string;
};

/** A full-height dark closer. The last card slides up over the stack and ends on this. */
export function PinRotateOutro({ children, className = "" }: PinRotateOutroProps) {
  return (
    <section data-pin-rotate-outro className={`relative flex min-h-[100svh] flex-col items-center justify-center bg-[#1a1a1a] px-[6vw] text-center text-white md:px-[8vw] ${className}`}>
      {children}
    </section>
  );
}
```

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

```tsx
"use client";

import { PinRotateIntro, PinRotateOutro, PinRotateSection, PinRotateSections, type PinRotateSectionsProps } from "@/components/dimaac/pin-rotate-sections";

// A short guide to five buildings. The cards are paper, the page behind them is ink, so the push-away
// reads clearly in both the light and the dark site theme.

const buildings = [
  {
    title: "Concrete Corner",
    image: "architecture/concrete-corner-3x2.jpg",
    alt: "A minimalist architectural corner with rough concrete walls, a black-framed window and gravel at its foot",
    text: "Rough board-marked concrete meets one black window frame. Nothing is hidden and nothing is added, so the light on the wall does all the talking.",
  },
  {
    title: "Balcony Study",
    image: "architecture/concrete-balconies-3x2.jpg",
    alt: "Concrete balconies stacked against a pale sky",
    text: "Stacked balconies cut hard shadows into the facade. Walk past at noon and again at dusk: it is a different building each time.",
  },
  {
    title: "The Red Wall",
    image: "architecture/red-wall-interior-3x2.jpg",
    alt: "A modern interior with a bold red textured wall and large windows onto a desert",
    text: "One saturated wall, a few pieces of furniture, and a window that frames the desert. The room asks very little of you and gives a lot back.",
  },
  {
    title: "White Corner",
    image: "architecture/white-corner-16x9.jpg",
    alt: "A white building corner with a teal-tinted window against a teal sky",
    text: "Flat white panels and a single tinted window turn a street corner into a sculpture. Best seen on a cloudless morning.",
  },
  {
    title: "Palm Court",
    image: "architecture/palm-pool-3x2.jpg",
    alt: "Minimalist architecture with palm trees standing on a platform of water",
    text: "Palms stand in a still sheet of water and the architecture simply gets out of the way. It is the quietest stop of the five.",
  },
];

const body = "font-[family-name:Raleway,sans-serif]";

const Pulse = () => (
  <svg viewBox="0 0 24 24" fill="none" aria-hidden="true" className="ml-[0.14em] inline h-[0.9em] w-[0.9em] self-center">
    <path d="M22 12H18L15 21L9 3L6 12H2" stroke="currentColor" strokeWidth="0.6" strokeLinecap="round" strokeLinejoin="round" />
  </svg>
);

const Heart = () => (
  <svg viewBox="0 0 24 24" fill="none" aria-hidden="true" className="ml-[0.14em] inline h-[0.9em] w-[0.9em] self-center">
    <path
      d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"
      stroke="currentColor"
      strokeWidth="0.6"
      strokeLinecap="round"
      strokeLinejoin="round"
    />
  </svg>
);

export default function Demo(props: Partial<PinRotateSectionsProps>) {
  const { children: _children, className = "", ...settings } = props;
  return (
    <div className={`${body} h-full w-full`}>
      <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Raleway:wght@100..900&display=swap" precedence="default" />

      <PinRotateSections {...settings} className={className}>
        <PinRotateIntro className="bg-[#1a1a1a]">
          <h2 className="flex flex-wrap items-center justify-center text-[clamp(34px,6.4vw,92px)] leading-[1.05] font-medium tracking-[-0.03em]">
            <span>Five</span>
            <span className="mx-[0.25em] flex items-center font-thin text-[#ffd9b3]">
              Buildings
              <Pulse />
            </span>
            <span>Worth the Trip</span>
          </h2>
          <p className="mt-5 max-w-[34rem] text-[clamp(15px,1.4vw,19px)] leading-relaxed opacity-75">Scroll down. Each stop pins to the page, then gets pushed back as the next one slides over it.</p>
        </PinRotateIntro>

        {buildings.map((building, index) => (
          <PinRotateSection key={building.title} className="gap-6 md:gap-0">
            <span className="text-[clamp(44px,12vw,64px)] leading-none font-semibold tracking-[-0.03em] md:text-[7vw]">({String(index + 1).padStart(2, "0")})</span>
            <div className="flex w-full flex-col items-start md:w-[60%]">
              <h3 className="mb-4 text-[clamp(30px,8vw,48px)] leading-none font-medium tracking-[-0.04em] uppercase md:mb-7 md:text-[3.6vw]">{building.title}</h3>
              <div className="w-full overflow-hidden rounded-[4px] bg-black/10">
                <img src={media(building.image)} alt={building.alt} loading="eager" decoding="async" draggable={false} className="block aspect-[16/9] max-h-[44svh] w-full object-cover md:max-h-[46svh]" />
              </div>
              <p className="mt-4 max-w-full text-[15px] leading-snug opacity-80 md:mt-6 md:max-w-[72%] md:text-base md:leading-relaxed">{building.text}</p>
            </div>
          </PinRotateSection>
        ))}

        <PinRotateOutro className="bg-[#1a1a1a]">
          <h2 className="flex flex-wrap items-center justify-center text-[clamp(34px,6.4vw,92px)] leading-[1.05] font-medium tracking-[-0.03em]">
            <span>Safe</span>
            <span className="mx-[0.25em] flex items-center font-thin text-[#ffd9b3]">
              Travels
              <Heart />
            </span>
            <span>Out There</span>
          </h2>
          <p className="mt-5 max-w-[34rem] text-[clamp(15px,1.4vw,19px)] leading-relaxed opacity-75">Go slowly, look up, and bring a camera.</p>
        </PinRotateOutro>
      </PinRotateSections>
    </div>
  );
}
```

## Agent prompt

```text
Add the Pin rotate sections component (<PinRotateSections />) from DiMaac UI to this project.

Docs: https://ui.dimaac.com/components/pin-rotate-sections
Source and dependencies (shadcn registry JSON): https://ui.dimaac.com/r/pin-rotate-sections.json

Install it with:
npx shadcn@latest add https://ui.dimaac.com/r/pin-rotate-sections.json

Then use it like this:
import { PinRotateSections } from "@/components/dimaac/pin-rotate-sections";
<PinRotateSections children={children} />

If the shadcn CLI isn't set up here, fetch the registry JSON above, write files[0].content to components/dimaac/pin-rotate-sections.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
```
