Scroll Story
A scrollytelling section: steps scroll on one side while a pinned visual swaps as each reaches mid screen and a progress rail fills. Inline on mobile.
Installation
npx shadcn@latest add @minidev/scroll-story
MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/scroll-story.json
Usage
import { ScrollStory } from "@/components/ui/scroll-story"
export function Example() {
return (
<ScrollStory />
)
}
API reference
When to use
Use for a 3–5 step explanation on a landing page. On large screens the visual is sticky; below lg each step shows its own visual inline, so nothing is lost on mobile. Each visual should be a compact panel (a DeviceFrame scaled down, a card). Swaps are instant under reduced motion. For a static grid of features use BentoLive.
Accessibility
- The section is labelled by its
<h2>througharia-labelledby, and each step title is an<h3>. - Each visual is shown once at a time: inline below
lg, and in the pinned panel fromlgup, where the inline copies aredisplay: none. - The progress rail and step dots are
aria-hidden. Under reduced motion the rail jumps, the panel swaps with no blur or rise, and the panel rows skip their entrance.
Frequently asked questions
How does it decide which step is active?
An IntersectionObserver with rootMargin: "-45% 0px -45% 0px" marks a step active when it crosses the middle tenth of the viewport. Each step is at least 60vh tall, so only one is in that band at a time.
Does it work inside a scrolling panel or modal?
Not as expected. The observer has no root, so it watches the browser viewport, not an overflow-auto container. Use it in the page's main scroll.
Can I control the active step or listen for changes?
No. There is no value or change callback. The active step comes only from scroll position, and the pinned visual swaps to that step's visual.
Dependencies
npm
Built from