Free · MIT licence · No dependencies

Stacking Cards Free React component

Sections that pin as you scroll and pile up like a deck. Each card sticks a little lower than the last, and the ones underneath shrink and dim as new cards slide over them. Great for services, case studies and process steps.

  • React
  • CSS
  • Scroll
  • Sticky
  • Sections
Stacking Cards

Get the code

Install in one linenpx shadcn@latest add https://alphenex.com/r/stacking-cards.json

Works with any React project through the shadcn CLI. Prefer to paste it yourself? Copy the two files below into components/alphenex/. No Tailwind or animation library needed.

import StackingCards from '@/components/alphenex/stacking-cards';

<StackingCards>
  <section className="card">Strategy</section>
  <section className="card">Design</section>
  <section className="card">Build</section>
  <section className="card">Launch</section>
</StackingCards>

How the stacking cards works

Every card is a position: sticky element with its own top value, the first one at top, the next one offset pixels lower, and so on. That alone makes the cards pin and pile up, with no JavaScript at all.

The depth effect is the JavaScript part. On each scroll frame the component measures how far every card has slid into its pinned spot, from 0 to 1. A card is then shrunk and darkened by the total of those values for all the cards above it in the pile, so the motion is continuous rather than stepped.

It finds the nearest scrolling parent itself, so the same component works for a full page or inside a scrolling panel, like the demo on this page.

Frequently asked questions

position: sticky stops working if any parent has overflow: hidden. Remove it, or use overflow: clip, which does not break sticky. The parent also needs to be taller than the cards.

Want motion like this on your website?

We design and build custom websites with motion, 3D and SEO built in. Websites from $500.

More free components

Explore our work