Container edges that fade only where there is more content.
Installation
Install the packages
npm install @prequelui/react motion@prequelui/react reuses the primitive library your components already depend on.
Add the component
npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/scroll-fade.jsonnpx shadcn@latest add https://animate.prequelui.terravidhal.me/r/scroll-fade.json
Turn on the motion
npx @prequelui/cli@latest animate scroll-fadeThe CLI finds the component through components.json, swaps the import and removes the CSS animation classes that Motion replaces.
Usage
Import the component and compose it exactly like the primitive it wraps. Motion is enabled by default; the tempo prop scales every duration and softens every spring.
import { ScrollFade } from "@/components/prequelui/effects/scroll-fade";
export default function Demo() {
return (
<ScrollFade size={44} className="h-40 w-[320px] overflow-y-auto rounded-xl border">
{rows.map((row) => <p key={row}>{row}</p>)}
</ScrollFade>
);
}import { ScrollFade } from "@/components/prequelui/scroll-fade";
export function Variant() {
return (
<ScrollFade tempo={1.2}>
…
</ScrollFade>
);
}Animation
The container paints a gradient mask on its own edges. The mask only exists on a side that still has content to reveal: at the top of the list the top fade is zero, at the bottom the bottom fade is zero, and the values settle with a short tween as you scroll.
- Edge amount ramps over half the fade size, from 0 to 1.
- Vertical, horizontal and both orientations are supported, including RTL.
- Scroll and resize both re-measure; the mask is removed when no edge is active.
- Reduced motion jumps straight to the target amount.
API Reference
Each part accepts the usual HTML props in addition to the motion props below. No accessibility prop is hidden behind the animation layer.
ScrollFade
| Prop | Type | Default |
|---|---|---|
| orientation | "vertical" | "horizontal" | "both" | "vertical" |
| size | number | 40 |
| enabled | boolean | true |
| transition | Transition | component spring or tween |
| asChild | boolean | false |
| className | string | — |