Sticky Deck

Stacking Cards on Scroll for React

Cards that pin one after another as you scroll. Each new card slides over the last while the deck behind it settles back a layer, scaling down and dimming, so the earlier cards' edges peek out above the front one. Click an edge to bring that card back.

  • Scroll
  • Cards
  • Sticky

Uses motion, clsx, tailwind-merge

Open in ChatGPTOpen in Claude
offsetStep16px
scaleTo0.94×
dimTo0.86
depth3
lift0.50×
liftBounce0.25
<StickyDeck />

The demo follows as you drag.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Sticky Deck: Cards that pin one after another as you scroll. Each new card slides over the last while the deck behind it settles back a layer, scaling down and dimming, so the earlier cards' edges peek out above the front one. Click an edge to bring that card back.
This demo, How It Works: An AI agent's four steps, each card with a piece of real product UI. The step list beside the deck follows the front card through `onActiveChange`, and clicking a step scrolls there through `apiRef`. Hover an edge that peeks out above the front card and it lifts; click it to bring that card back.

1. Install it:
   npx shadcn@latest add @keyframeui/sticky-deck-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/sticky-deck-demo.json instead.)
   It adds the demo, components/sticky-deck-demo.tsx, and the component, components/ui/sticky-deck.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <StickyDeck> on its own.

3. These props set its feel. Change them before you change the file:
   - offsetStep (default 16): How far each buried card's top edge peeks out above the card in front of it, in px.
   - scaleTo (default 0.94): Scale of the card one layer back, from its top edge. Each further layer multiplies it again, so the deck recedes. Not applied with reduced motion.
   - dimTo (default 0.86): Brightness of the card one layer back, from 0 to 1. Each further layer multiplies it again. `1` turns dimming off.
   - depth (default 3): How many cards stay visible behind the front one. A card pushed further back slides under its neighbor and fades out.
   - lift (default 0.5): How far a buried card's edge rises under the pointer, as a share of `offsetStep`. `0` turns the lift off.
   - liftBounce (default 0.25): How much that edge overshoots as it lifts and settles back, from `0` (none) up.

4. Don't change, in components/ui/sticky-deck.tsx:
   - A card's travel is native `position: sticky`; only its settling back is driven, by transform and opacity from one `position` motion value, so scrolling never re-renders a card.
   - `position` is read from the deck's live rect on every scroll frame, so content shifting above the deck never leaves the cards out of step.
   - Cards scale from their top edge (`origin-top`), so a buried card's edge peeks out above the one in front; the dimming is a black layer's opacity on `rounded-[inherit]`, not a filter.
   - A buried card's edge (`data-buried`) is a handle: clicking it, or focusing inside a hidden card, scrolls the deck back to that card.
   - Reduced motion drops the rise, scale and lift; cards stay sticky and still dim.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/sticky-deck.md

Installation

Add the component on its own with the CLI, or copy the file in by hand.

The CLI writes components/ui/sticky-deck.tsx and installs motion, clsx and tailwind-merge. It needs the @keyframeui registry in components.json; add it once per project.

npx shadcn@latest add @keyframeui/sticky-deck

Examples

Finished sections built with Sticky Deck. Each one installs whole, with the component included.

Case Studies

A studio portfolio on photo cards, with tighter edges and a deeper dim for a dark page. Each photo settles from a slight zoom as its card lands, driven by `useStickyDeckCard()`, and the counter at the top rolls to the front card's number.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Sticky Deck: Cards that pin one after another as you scroll. Each new card slides over the last while the deck behind it settles back a layer, scaling down and dimming, so the earlier cards' edges peek out above the front one. Click an edge to bring that card back.
This demo, Case Studies: A studio portfolio on photo cards, with tighter edges and a deeper dim for a dark page. Each photo settles from a slight zoom as its card lands, driven by `useStickyDeckCard()`, and the counter at the top rolls to the front card's number.

1. Install it:
   npx shadcn@latest add @keyframeui/sticky-deck-case-studies-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/sticky-deck-case-studies-demo.json instead.)
   It adds the demo, components/sticky-deck-case-studies-demo.tsx, and the component, components/ui/sticky-deck.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <StickyDeck> on its own.

3. These props set its feel. Change them before you change the file:
   - offsetStep (default 16): How far each buried card's top edge peeks out above the card in front of it, in px.
   - scaleTo (default 0.94): Scale of the card one layer back, from its top edge. Each further layer multiplies it again, so the deck recedes. Not applied with reduced motion.
   - dimTo (default 0.86): Brightness of the card one layer back, from 0 to 1. Each further layer multiplies it again. `1` turns dimming off.
   - depth (default 3): How many cards stay visible behind the front one. A card pushed further back slides under its neighbor and fades out.
   - lift (default 0.5): How far a buried card's edge rises under the pointer, as a share of `offsetStep`. `0` turns the lift off.
   - liftBounce (default 0.25): How much that edge overshoots as it lifts and settles back, from `0` (none) up.

4. Don't change, in components/ui/sticky-deck.tsx:
   - A card's travel is native `position: sticky`; only its settling back is driven, by transform and opacity from one `position` motion value, so scrolling never re-renders a card.
   - `position` is read from the deck's live rect on every scroll frame, so content shifting above the deck never leaves the cards out of step.
   - Cards scale from their top edge (`origin-top`), so a buried card's edge peeks out above the one in front; the dimming is a black layer's opacity on `rounded-[inherit]`, not a filter.
   - A buried card's edge (`data-buried`) is a handle: clicking it, or focusing inside a hidden card, scrolls the deck back to that card.
   - Reduced motion drops the rise, scale and lift; cards stay sticky and still dim.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/sticky-deck.md

Pricing

Plans dealt in order, each one reading "Everything in Pro, plus" as it lands on the plan it builds on. Taller edges keep every tier's color showing at the top of the deck.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Sticky Deck: Cards that pin one after another as you scroll. Each new card slides over the last while the deck behind it settles back a layer, scaling down and dimming, so the earlier cards' edges peek out above the front one. Click an edge to bring that card back.
This demo, Pricing: Plans dealt in order, each one reading "Everything in Pro, plus" as it lands on the plan it builds on. Taller edges keep every tier's color showing at the top of the deck.

1. Install it:
   npx shadcn@latest add @keyframeui/sticky-deck-pricing-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/sticky-deck-pricing-demo.json instead.)
   It adds the demo, components/sticky-deck-pricing-demo.tsx, and the component, components/ui/sticky-deck.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <StickyDeck> on its own.

3. These props set its feel. Change them before you change the file:
   - offsetStep (default 16): How far each buried card's top edge peeks out above the card in front of it, in px.
   - scaleTo (default 0.94): Scale of the card one layer back, from its top edge. Each further layer multiplies it again, so the deck recedes. Not applied with reduced motion.
   - dimTo (default 0.86): Brightness of the card one layer back, from 0 to 1. Each further layer multiplies it again. `1` turns dimming off.
   - depth (default 3): How many cards stay visible behind the front one. A card pushed further back slides under its neighbor and fades out.
   - lift (default 0.5): How far a buried card's edge rises under the pointer, as a share of `offsetStep`. `0` turns the lift off.
   - liftBounce (default 0.25): How much that edge overshoots as it lifts and settles back, from `0` (none) up.

4. Don't change, in components/ui/sticky-deck.tsx:
   - A card's travel is native `position: sticky`; only its settling back is driven, by transform and opacity from one `position` motion value, so scrolling never re-renders a card.
   - `position` is read from the deck's live rect on every scroll frame, so content shifting above the deck never leaves the cards out of step.
   - Cards scale from their top edge (`origin-top`), so a buried card's edge peeks out above the one in front; the dimming is a black layer's opacity on `rounded-[inherit]`, not a filter.
   - A buried card's edge (`data-buried`) is a handle: clicking it, or focusing inside a hidden card, scrolls the deck back to that card.
   - Reduced motion drops the rise, scale and lift; cards stay sticky and still dim.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/sticky-deck.md

Props

children

TypeReact.ReactNode

One StickyDeckCard per card, in order. Give them the same height: a taller card further back would show below the front one.

top

Typenumber | stringDefault96

Where the front card pins, from the top of the scrollport. A number is in px; a string is any CSS length, like "calc(var(--header) + 3rem)". Leave room above it for the peeking edges: depth * offsetStep.

offsetStep

TypenumberDefault16

How far each buried card's top edge peeks out above the card in front of it, in px.

scaleTo

TypenumberDefault0.94

Scale of the card one layer back, from its top edge. Each further layer multiplies it again, so the deck recedes. Not applied with reduced motion.

dimTo

TypenumberDefault0.86

Brightness of the card one layer back, from 0 to 1. Each further layer multiplies it again. 1 turns dimming off.

depth

TypenumberDefault3

How many cards stay visible behind the front one. A card pushed further back slides under its neighbor and fades out.

lift

TypenumberDefault0.5

How far a buried card's edge rises under the pointer, as a share of offsetStep. 0 turns the lift off.

liftBounce

TypenumberDefault0.25

How much that edge overshoots as it lifts and settles back, from 0 (none) up.

hold

Typenumber | stringDefault"20vh"

How much more scrolling the finished deck stays pinned for once the last card lands, before the whole deck moves on with the page. A number is in px; a string is any CSS length. 0 lets it go straight away.

containerRef

TypeReact.RefObject<HTMLElement | null>

The scroll container, when the deck scrolls inside an overflow-y-auto box. Leave it out to pin against the window.

onActiveChange

Type(index: number) => void

Called with the front card's index whenever it changes: once the next card covers half of it. Use it for a step list, a counter or a progress bar.

apiRef

TypeReact.Ref<StickyDeckApi>

Receives { scrollTo(index) }, which scrolls the page (smoothly, or instantly with reduced motion) until that card is at the front. For a step list or a table of contents beside the deck.

className

Typestring

Classes for the deck, a flex column. The gap between cards (gap-8 by default) is also how long each card rests at the front before the next one starts covering it.

card.className

Typestring

StickyDeckCard: classes for the card itself: background, rounding, padding and a fixed height. An upward shadow (shadow-[0_-12px_32px_-16px_rgb(0_0_0/0.25)]) falls on the card behind as it slides over. The dimming layer follows the rounding.

card.children

TypeReact.ReactNode

StickyDeckCard: the card's content. Tabbing into a link or button in a hidden card scrolls the deck to it, and clicking a buried card's edge brings it to the front instead of following a link there.

useStickyDeckCard()

Type() => { index, progress, depth }

Call it in a component inside a StickyDeckCard to tie effects to the deck. progress is a MotionValue that runs 0 → 1 as the card travels into place; depth counts the cards covering it, fractionally while one slides over.