Scroll Stack
Successive cards scale into focus and fade as the next section takes their place.
Scroll inside the preview to reveal each card.
Component preview
Install using CLI
npx shadcn@latest add "https://www.obsidianui.dev/r/scroll-stack.json"Usage
Code
"use client";
import { useRef } from "react";
import { ScrollStack } from "@/components/block/scroll-stack";
const cards = [
{
"id": "design",
"title": "Start with an idea.",
"description": "Give your next interface a clear purpose and room to breathe.",
"bgColor": "#e6d5f7",
"textColor": "#30233c"
},
{
"id": "motion",
"title": "Make it feel right.",
"description": "Use motion to guide attention and connect every interaction.",
"bgColor": "#d5e8b5",
"textColor": "#24351c"
},
{
"id": "build",
"title": "Make it yours.",
"description": "Build something worth sharing with ObsidianUI.",
"bgColor": "#f7c698",
"textColor": "#432d1c"
}
];
export default function Demo() {
const scroller = useRef<HTMLDivElement>(null);
return <div ref={scroller} tabIndex={0} aria-label="Scroll effect preview" className="relative h-[400px] overflow-y-auto overscroll-contain" style={{ containerType: "size" }}>
<ScrollStack cards={cards} scroller={scroller} viewportHeight="100cqh" contained />
</div>;
}Install Manually
1
Install dependencies
npm install gsap
2
Copy the source code
Copy into components/block/scroll-stack.jsx
3
Add the CSS file
Copy into lib/effects/scroll-stack/styles.css
Preview behavior
Scroll inside the preview to reveal each card. The effect stays inside its container and respects reduced motion preferences.
Last updated on