GooseUI

Components

Stacking Cards


Cards that stack on top of each other as user scrolls, using CSS position: sticky and scroll-driven animations.

Browser Support

Scroll-driven animations

Animates cards as they stack on scroll.

Your browser:

Preview

Scroll inside the container to see cards stack.

Scroll down, the steps stack on top of each other

01

Idea

Describe the problem in one sentence and check that people actually need the answer.

  • Five customer interviews
  • One clear promise
  • A short list of must-haves
02

Design

Turn the idea into screens: layout, type and a single accent color.

  • Wireframes in a day
  • A small set of components
  • Review with the team
03

Development

Build the first version in small steps, with tests on every change.

  • Weekly releases
  • Automated checks
  • Code review for each change
04

Launch

Open access, watch the numbers and fix the weak spots first.

  • Public announcement
  • Metrics from day one
  • Feedback in one inbox

Installation

npx shadcn@latest add @gooseui/stacking-cards
pnpm dlx shadcn@latest add @gooseui/stacking-cards
yarn dlx shadcn@latest add @gooseui/stacking-cards
bunx --bun shadcn@latest add @gooseui/stacking-cards

Usage

import { StackingCardsContainer, StackingCard } from "@/components/effects/stacking-cards"

// The card only sticks and stacks, its look is up to you
<StackingCardsContainer stickyTop={24} stackOffset={14} endSpace={26}>
  <StackingCard>
    <div className="grid gap-6 p-8 md:grid-cols-2">
      <div>
        <span className="text-6xl font-semibold text-muted-foreground/40">01</span>
        <h3 className="text-2xl font-semibold">Idea</h3>
        <p className="text-muted-foreground">Describe the problem in one sentence.</p>
      </div>
      <Illustration />
    </div>
  </StackingCard>
  <StackingCard>{/* ... */}</StackingCard>
</StackingCardsContainer>

// With scroll-driven animation
import { StackingCardsAnimated, StackingCardsStyles } from "@/components/effects/stacking-cards"

<StackingCardsStyles />
<StackingCardsAnimated>
  <div className="p-6 rounded-xl border bg-card">Card 1</div>
  <div className="p-6 rounded-xl border bg-card">Card 2</div>
</StackingCardsAnimated>

How it works

.stacking-card {
  position: sticky;
  top: calc(var(--sticky-top) + var(--index) * var(--stack-offset));
  z-index: calc(var(--index) + 1);
}

/* With scroll animation */
.stacking-card-wrapper {
  animation: stack-scale linear;
  animation-timeline: view();
  animation-range: exit -100px exit 100px;
}

@keyframes stack-scale {
  to {
    transform: scale(0.95);
  }
}

Props

PropTypeDefaultDescription
indexnumberautoCard index for stacking offset (auto-assigned). Props index, stickyTop and stackOffset go on StackingCard; the container sets them for you
stickyTopnumber100Base sticky top position in pixels
stackOffsetnumber20Offset between stacked cards in pixels
endSpacenumber | string"50vh"Empty space after the last card (px or CSS length), inside the sticky range. The scroll ends when the last card is in place: scrollport height - stickyTop - stackOffset * (cards - 1) - card height - gap above it. Container padding does not work: sticky cards are bounded by the content box
classNamestring-Additional CSS classes