Scroll Reveal
Content that moves from an offset into place while it scrolls into view.
$npx shadcn@latest add https://framebrick.co/r/scroll-reveal.jsonFrom the Nitip template, see it in context.
1. Tied to scroll
Progress runs from the bottom of the viewport to the top of the block.
2. Reversible
Scroll back up and it plays backwards — no snapping, no easing.
import { ScrollReveal } from "@/components/ui/scroll-reveal";
const cards = [
{ title: "Tied to scroll", body: "Progress runs from the bottom of the viewport to the top of the block." },
{ title: "Reversible", body: "Scroll back up and it plays backwards — no snapping, no easing." },
];
export default function ScrollRevealDemo() {
return (
<div className="flex w-full max-w-md flex-col gap-4">
{cards.map((card, i) => (
<ScrollReveal key={card.title} from={{ y: 40, scale: 0.96, opacity: 0 }}>
<div className="rounded-lg border bg-card p-5">
<p className="text-sm font-medium">
{i + 1}. {card.title}
</p>
<p className="mt-1 text-sm text-muted-foreground">{card.body}</p>
</div>
</ScrollReveal>
))}
</div>
);
}Examples
First pixel, another spring
Springs into place once as soon as any of it shows, on Semono's spring (200 / 30 / 1) from 40 px lower.
Starts at the first pixel
amount={0}: it springs as soon as any of it shows, once.
On Semono's spring
spring 200 / 30 / 1, from 40px lower — the Semono reveal.
import { ScrollReveal } from "@/components/ui/scroll-reveal";
const cards = [
{ title: "Starts at the first pixel", body: "amount={0}: it springs as soon as any of it shows, once." },
{ title: "On Semono's spring", body: "spring 200 / 30 / 1, from 40px lower — the Semono reveal." },
];
export default function ScrollRevealFirstPixelDemo() {
return (
<div className="flex w-full max-w-md flex-col gap-4">
{cards.map((card) => (
<ScrollReveal
key={card.title}
trigger="enter"
amount={0}
spring={{ stiffness: 200, damping: 30, mass: 1 }}
from={{ y: 40, opacity: 0.001 }}
>
<div className="rounded-lg border bg-card p-5">
<p className="text-sm font-medium">{card.title}</p>
<p className="mt-1 text-sm text-muted-foreground">{card.body}</p>
</div>
</ScrollReveal>
))}
</div>
);
}<ScrollReveal trigger="enter" amount={0} spring={{ stiffness: 200, damping: 30, mass: 1 }} from={{ y: 40, opacity: 0.001 }}>
<Card />
</ScrollReveal>Installation
$ npx shadcn@latest add https://framebrick.co/r/scroll-reveal.json1. Install the dependencies.
npm install motion clsx tailwind-merge2. Add
cn()tolib/utils.ts(skip if shadcn already created it).import { clsx, type ClassValue } from "clsx"; import { extendTailwindMerge } from "tailwind-merge"; /* tailwind-merge must know the site's type scale (globals.css) is a font size, not a text color — otherwise cn("text-h6 text-muted-foreground") drops text-h6. */ const twMerge = extendTailwindMerge({ extend: { classGroups: { "font-size": [{ text: ["display", "h1", "h2", "h3", "h4", "h5", "h6"] }] } }, }); export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); }3. Copy the component into
components/ui/scroll-reveal.tsx."use client"; import * as React from "react"; import { animate } from "motion/react"; import { cn } from "@/lib/utils"; /* * Scroll Reveal — content that arrives from an offset as it scrolls into view, either way: * * trigger="scroll" (default, from Framer's "Scroll Transform · In View", as used across the Nitip pages): * progress is 0 when the frame's top reaches the bottom of the viewport and 1 when its bottom does, tied directly * to scroll — no easing, no jump — so scrolling back up plays it backwards. The transform is written straight to * the element in a passive scroll listener, as Framer does: it never lags a frame behind, and the frame itself * never moves, so measuring stays correct when images load late. * * trigger="enter" (from Titen, where every block, card and row uses it): it springs into place once, the first time * half of it is in view, and stays. Framer's rule for a block taller than the screen is half the screen instead, * which is what the threshold below works out. Titen's spring: stiffness 320, damping 55, mass 1, delay 0.05s. * Two options come from Semono, whose blocks start when the first pixel shows (amount 0) or half of it (0.5) on its * own spring (stiffness 200, damping 30, mass 1 — at rest in about 0.75s against Titen's 1s, because 320 / 55 is * the more heavily damped of the two): `amount` takes any share from 0 to 1 and `spring` the three numbers. * * Static with reduced motion, both ways. */ export type ScrollRevealOffset = { x?: number; y?: number; scale?: number; opacity?: number }; export type ScrollRevealProps = { children: React.ReactNode; /** Where the content starts: pixels for x/y, a factor for scale, 0–1 for opacity. */ from?: ScrollRevealOffset; /** "scroll" follows the scroll position; "enter" springs into place once, when half of it is in view. */ trigger?: "scroll" | "enter"; /** Seconds before the spring starts, for "enter". */ delay?: number; /** For "enter": how much of it must be in view before it starts, from 0 (its first pixel) to 1 (all of it). Half by default. */ amount?: number; /** For "enter": the spring. Titen's by default (320 / 55 / 1); Semono's is 200 / 30 / 1. */ spring?: { stiffness?: number; damping?: number; mass?: number }; className?: string; }; const transform = ({ x = 0, y = 0, scale = 1 }: ScrollRevealOffset) => `translate3d(${x}px, ${y}px, 0) scale(${scale})`; export function ScrollReveal({ children, from = { y: 60, opacity: 0 }, trigger = "scroll", delay = 0.05, amount, spring, className, }: ScrollRevealProps) { const frame = React.useRef<HTMLDivElement>(null); const content = React.useRef<HTMLDivElement>(null); const key = JSON.stringify(from); const springKey = JSON.stringify(spring ?? {}); React.useEffect(() => { const frameEl = frame.current; const contentEl = content.current; if (!frameEl || !contentEl) return; const start = JSON.parse(key) as ScrollRevealOffset; const rest = () => { contentEl.style.transform = ""; contentEl.style.opacity = ""; }; if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) { rest(); return; } if (trigger === "enter") { /* The share asked for — half by default — of the block, or of the screen for a block taller than the screen: Motion's amount alone never fires for anything taller than the viewport over that share. */ const height = frameEl.getBoundingClientRect().height || 1; /* 1 means 99%: a block that is a subpixel short of the screen's edge never reports a ratio of exactly 1. */ const share = Math.min(0.99, Math.max(0, amount ?? 0.5)); const threshold = Math.min(share, (share * window.innerHeight) / height); const config = JSON.parse(springKey) as NonNullable<ScrollRevealProps["spring"]>; let played: ReturnType<typeof animate> | undefined; const observer = new IntersectionObserver( ([entry]) => { if (!entry.isIntersecting) return; observer.disconnect(); played = animate( 0, 1, { type: "spring", stiffness: config.stiffness ?? 320, damping: config.damping ?? 55, mass: config.mass ?? 1, delay, onUpdate: (progress) => { const left = 1 - progress; contentEl.style.transform = transform({ x: (start.x ?? 0) * left, y: (start.y ?? 0) * left, scale: 1 + ((start.scale ?? 1) - 1) * left, }); contentEl.style.opacity = `${1 + ((start.opacity ?? 1) - 1) * left}`; }, onComplete: rest, }, ); }, { threshold }, ); observer.observe(frameEl); return () => { observer.disconnect(); played?.stop(); }; } const update = () => { const rect = frameEl.getBoundingClientRect(); const progress = rect.height ? (window.innerHeight - rect.top) / rect.height : 1; const left = 1 - Math.min(1, Math.max(0, progress)); contentEl.style.transform = transform({ x: (start.x ?? 0) * left, y: (start.y ?? 0) * left, scale: 1 + ((start.scale ?? 1) - 1) * left, }); contentEl.style.opacity = `${1 + ((start.opacity ?? 1) - 1) * left}`; }; update(); const observer = new ResizeObserver(update); observer.observe(document.body); window.addEventListener("resize", update); window.addEventListener("scroll", update, { passive: true }); return () => { observer.disconnect(); window.removeEventListener("resize", update); window.removeEventListener("scroll", update); }; }, [key, trigger, delay, amount, springKey]); return ( <div ref={frame} className={cn("relative", className)}> <div ref={content} style={{ transform: transform(from), opacity: from.opacity ?? 1 }} className="will-change-transform" > {children} </div> </div> ); }
Usage
import { ScrollReveal } from "@/components/ui/scroll-reveal";
<ScrollReveal from={{ y: 60, opacity: 0 }}>
<h2>Everything we make, in one place</h2>
</ScrollReveal>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | What moves into place. |
| from | { x?, y?, scale?, opacity? } | { y: 60, opacity: 0 } | Where it starts: pixels for x/y, a factor for scale, 0–1 for opacity. |
| trigger | "scroll" | "enter" | "scroll" | "scroll" follows the scroll position; "enter" springs into place once, the first time half of it is in view. |
| delay | number | 0.05 | Seconds before the spring starts, for "enter". |
| amount | number | 0.5 | For "enter": how much of it must be in view before it starts, from 0 (its first pixel) to 1 (all of it). |
| spring | { stiffness?, damping?, mass? } | { 320, 55, 1 } | For "enter": the spring. Titen's by default; Semono's is { stiffness: 200, damping: 30, mass: 1 }. |
| className | string | — | Classes for the frame, which never moves. |
- Tied directly to scroll, not to a timer: progress is 0 when the block's top reaches the bottom of the viewport and 1 when its bottom does, so scrolling back up plays it backwards.
- With trigger="enter" it springs once instead (Titen: stiffness 320, damping 55, mass 1). The threshold is half the block, or half the screen for a block taller than the screen — Motion's `amount: 0.5` alone never fires for anything over twice the viewport. `amount` moves that share (the same rule holds for any share, and 1 means 99%, so a block that is a subpixel short of the screen's edge still fires) and `spring` sets the three numbers. Titen's spring is at rest in about 1 s; Semono starts at the first pixel (amount 0) or at half, on stiffness 200, damping 30, at rest in about 0.75 s — 320 / 55 is the more heavily damped of the two.
- Static with reduced motion.
AI prompt
Paste into v0, Lovable, Bolt or Claude to rebuild this component in your own project.
Create a React + Tailwind CSS component called ScrollReveal (no animation library).
- A frame that never moves, holding the content. The content starts at a given offset ({x, y, scale, opacity})
and reaches its resting state as the block scrolls into view.
- In a passive scroll listener: progress = (innerHeight - rect.top) / rect.height, clamped 0–1, left = 1 - progress;
write transform = translate3d(x*left, y*left, 0) scale(1 + (scale-1)*left) and opacity = 1 + (opacity-1)*left
straight to the element's style. Linear, no easing, reversible.
- Re-measure on resize with a ResizeObserver on document.body (images load late).
- Render the starting transform inline so there is no flash before the first scroll event.
- Skip everything when prefers-reduced-motion is set.
- trigger "enter" instead springs the content into place once, with Motion's animate() driving the same transform and opacity
from 0 to 1 progress (stiffness 320, damping 55, mass 1 by default), after `delay` seconds, the first time an
IntersectionObserver reports the frame. Its threshold is share = amount (default 0.5, clamped to 0–0.99, because a ratio
of exactly 1 is never reported when the block is a subpixel short of the edge), or
share × innerHeight / height for a frame taller than the screen, so a tall block still fires. A `spring` prop overrides
stiffness, damping and mass; amount 0 starts at the first pixel.










