Stacked Scroll Gallery
Pinned layered media stack — the next panel rises from the bottom and physically covers the current one, driven directly by scroll. Fully reversible, with per-card rounding and a live next-card preview strip.
Installation#
pnpm dlx shadcn@latest add @davinciui/stacked-scroll-galleryUsage#
API Reference#
| Prop | Type | Default |
|---|---|---|
itemsMedia panels in stack order. Each item needs src (image or video URL), optional type ('auto' | 'image' | 'video'), alt and poster. Supports any item count. | StackedScrollGalleryItem[] | — |
viewportHeightHeight of the pinned viewport (any CSS length). | string | "100vh" |
scrollDistancePerItemScroll distance devoted to each transition, in vh. Total track = viewport + distance × (items − 1). | number | 100 |
previewHeightPreview strip (px) of the incoming card visible at rest. Scales down automatically on small screens. | number | 44 |
radiusCorner radius (px) applied to every card independently. | number | 20 |
gutterInset (px) between the viewport edge and the cards on every side. | number | 22 |
fitHow media fills its card. | "cover" | "contain" | "fill" | "cover" |
positionMedia focal point (CSS object-position). | string | "50% 50%" |
smoothingScroll-follow smoothing 0 (direct) to 1. Kept low so scrubbing stays responsive; 0 disables interpolation. | number | 0.14 |
easingEasing applied to each transition's local progress. | "linear" | "easeInOut" | ((t: number) => number) | "linear" |
dimmingDim outgoing cards as the next panel travels over them. | boolean | true |
dimStrengthMax dim overlay opacity (0–1) when a card is fully covered. | number | 0.3 |
enabledWhen false, renders a static accessible list instead of the pinned scroll effect. | boolean | true |
pauseOffscreenVideosPause videos that are not the active (or adjacent) panel. | boolean | true |
backgroundSurrounding background color. When omitted, the gallery follows the theme (light zinc in light mode, near-black in dark mode). | string | — |
Accessibility#
The section has an aria-label, inactive cards are aria-hidden, each image or video has alt or aria-label, and a polite live region announces the active item. There is no keyboard control beyond normal scrolling.
Motion#
Card transforms and dimming follow scroll progress, with smoothing, easing, dimming, and dimStrength props; videos pause when offscreen. prefers-reduced-motion disables smoothing and autoplay but not the stacked movement itself.
View source
Keep in mind
Need a custom component?
I build bespoke UI components & websites tailored to your brand.

