$npx @dinachi/cli@latest add scroll-reveal
Scroll down.
Uncovered edge-first as it arrives.
directionup
down
left
right
distancedurationrepeatfeature.tsx
import { useRef } from "react"
import { ScrollReveal } from "@/components/ui/scroll-reveal"
export function Feature() {
const scrollport = useRef<HTMLDivElement>(null)
return (
<div ref={scrollport} className="h-60 overflow-y-auto">
<div className="h-64" />
<ScrollReveal root={scrollport} margin="0px">
<div className="rounded-lg border p-4">Uncovered edge-first as it arrives.</div>
</ScrollReveal>
</div>
)
}Usage
import { ScrollReveal } from "@/components/ui/scroll-reveal"
export function Features() {
return (
<ScrollReveal>
<FeatureGrid />
</ScrollReveal>
)
}Examples
Scroll down.
Uncovered edge-first as it arrives.
A block uncovered edge-first as it arrives.
import { ScrollReveal } from '@/components/ui/scroll-reveal';
export function Example() {
return (
<ScrollReveal>
<FeatureGrid />
</ScrollReveal>
);
}Scroll down.
up
down
left
right
The aperture opens against the travel.
import { ScrollReveal } from '@/components/ui/scroll-reveal';
export function Example() {
return (
<div className="space-y-40">
{(['up', 'down', 'left', 'right'] as const).map((direction) => (
<ScrollReveal key={direction} direction={direction}>
<Block>{direction}</Block>
</ScrollReveal>
))}
</div>
);
}Scroll down.
Deploys
Incidents
Costs
Sibling reveals offset by a small delay.
import { ScrollReveal } from '@/components/ui/scroll-reveal';
const panels = ['Deploys', 'Incidents', 'Costs'];
export function Example() {
return (
<div className="space-y-3">
{panels.map((panel, index) => (
// Keep the step in the 0.03-0.08s range. Past that the last block is
// late enough to read as a wait.
<ScrollReveal key={panel} delay={index * 0.06}>
<Block>{panel}</Block>
</ScrollReveal>
))}
</div>
);
}Notes
Motion tier
Needs motion. add --all skips it; install with add --motion or by name.
Direction
The aperture opens against the travel. Use up for content read top to bottom.
| Direction | Content travels | Aperture opens from | | --- | --- | --- | | up | Up | Top | | down | Down | Bottom | | left | Left | Right | | right | Right | Left |
When to use it
- One hero block or feature grid the reader has not seen yet.
- Skip it for content reached by deep link or revisited, and for content that must show without JS: the hidden state is a real style.
- For a list, use Stagger List.
Behaviour
- Reveals once by default. With
repeat, leaving view resets the block instantly. - A block shorter than the
margininset at the very bottom of the page never reveals. Pass"0px"for trailing content. rootmust be an ancestor of the content, or the block stays hidden. Set it inside a dialog body, sidebar or other scroll container.- A plain wrapper
divis observed.ref,classNameand other props go to the inner animated element.
API
direction"up" | "down" | "left" | "right" = "up"
Direction of travel. The aperture opens against it.distancenumber = 8
Travel in pixels.durationnumber = 0.3
Seconds. The easing front-loads the travel.delaynumber = 0
Seconds after entering view. Keep cascade steps between 0.03 and 0.08.repeatboolean = false
Replays each time the block re-enters view.marginstring = "0px 0px -100px 0px"
Root margin for the trigger. Pass "0px" for trailing content with nothing below it.amountnumber | "some" | "all" = "some"
How much must be visible. A block taller than the root never reaches a number.rootRefObject<Element>
A scrollable ancestor to observe instead of the viewport.Accessibility
- Reduced motion keeps the fade, drops the wipe and travel.
<MotionConfig reducedMotion>is honoured. - The hidden block stays in the DOM, so screen readers reach it early.