Scroll & Parallax
The 11 effects SP01–SP11: purpose, API, options, examples, reduced motion and cost.
Experimental and not on npm
These effects map the native scroll position to a property. Geometry is cached and re-read only when it changes, pinning is CSS position: sticky, and nothing hijacks scrolling. Effects inside a <ScrollScene> share its timeline; others create their own, for the page or for a source container. An ancestor with overflow: hidden, auto or scroll becomes the sticky container: use overflow: clip instead.
SP01 · Depth parallax
<ScrollLayer> moves a layer of a scene by distance multiplied by depth, on either axis. Keep text in layers with a depth close to 1 so that it stays readable.
- Import
@neshel-ui/animations/scroll- API
depthParallax, ScrollLayer, ScrollScene- Stylesheet
@neshel-ui/animations/scroll.css- Reduced motion
static— the decoration or content stays still- Performance
- Transform and opacity, one write per frame through the shared scheduler; no layout work per frame.
Loading the example…
"use client";
import "@neshel-ui/animations/scroll.css";
import { ScrollLayer, ScrollScene } from "@neshel-ui/animations/scroll";
export default function SP01Example() {
return (
<ScrollScene length={2} stageClassName="rounded-xl bg-neshel-muted">
<ScrollLayer
depth={0.4}
distance={300}
className="absolute left-[10%] top-[45%] size-24 rounded-xl bg-neshel-accent"
aria-hidden="true"
/>
<ScrollLayer
depth={1.4}
distance={300}
className="rounded-xl border border-neshel-border bg-neshel-surface p-6 text-neshel-surface-foreground absolute left-[45%] top-[45%]"
>
Foreground layer
</ScrollLayer>
</ScrollScene>
);
}Options: DepthParallaxOptions
DepthParallaxOptions
| Prop | Type | Default | Description |
|---|---|---|---|
| axis | "x" | "y" | "y" | Movement axis (default "y"). |
| depth | number | — | Speed factor: positive moves against the scroll (foreground), negative lags (background). −5…5, default 1. |
| distance | number | — | Travel at depth 1 over the whole range, px (0–2000, default 200). |
| range | readonly [RangeInput, RangeInput] | — | Range of the effect's own timeline (ignored with timeline). |
| reducedMotion | ReducedMotion | — | — |
| scrollAxis | ScrollAxis | "block" | Scroll axis of the effect's own timeline (default "block"). |
| smooth | boolean | SpringOptions | SpringPreset | — | SP10 spring smoothing of the effect's own timeline. |
| source | Element | Window | null | — | Scroll container of the effect's own timeline (default: the root scroller). |
| timeline | ScrollProgress | — | A shared timeline (e.g. from useScrollScene()); otherwise the effect creates one. |
SP02 · Scrubbed transform
scrubTransform interpolates between two poses (translateX, translateY, rotateZ, scale, opacity) as the element crosses the viewport, with an easing. Scrolling back reverses it exactly.
- Import
@neshel-ui/animations/scroll- API
scrubTransform, ScrollEffect- Stylesheet
- none needed
- Reduced motion
static— the decoration or content stays still- Performance
- Transform and opacity, one write per frame through the shared scheduler; no layout work per frame.
"use client";
import {
ScrollEffect,
type ScrubTransformOptions,
scrubTransform,
} from "@neshel-ui/animations/scroll";
export default function SP02Example() {
return (
<ScrollEffect
preset={scrubTransform}
options={
{
from: { translateX: -120, rotateZ: -8, opacity: 0.3 },
to: { translateX: 0, rotateZ: 0, opacity: 1 },
} satisfies ScrubTransformOptions
}
className="rounded-xl border border-neshel-border bg-neshel-surface p-6 text-neshel-surface-foreground"
>
Scroll moves me; scrolling back reverses me.
</ScrollEffect>
);
}Options: ScrubTransformOptions
ScrubTransformOptions
| Prop | Type | Default | Description |
|---|---|---|---|
| easing | Easing | EasingPreset | — | — |
| from | ScrubPose | — | — |
| range | readonly [RangeInput, RangeInput] | — | Range of the effect's own timeline (ignored with timeline). |
| reducedMotion | ReducedMotion | — | — |
| scrollAxis | ScrollAxis | "block" | Scroll axis of the effect's own timeline (default "block"). |
| smooth | boolean | SpringOptions | SpringPreset | — | SP10 spring smoothing of the effect's own timeline. |
| source | Element | Window | null | — | Scroll container of the effect's own timeline (default: the root scroller). |
| timeline | ScrollProgress | — | A shared timeline (e.g. from useScrollScene()); otherwise the effect creates one. |
| to | ScrubPose | — | — |
SP03 · Scroll progress bar
<ScrollProgressBar> is a decorative, aria-hidden bar for the page or a source; position places it at the top, the bottom or in the flow. scrollProgress writes the same value as --neshel-scroll-progress.
- Import
@neshel-ui/animations/scroll- API
ScrollProgressBar, scrollProgress- Stylesheet
@neshel-ui/animations/scroll.css- Reduced motion
reduced— a smaller signal remains because it conveys state- Performance
- Writes one custom property, natively with scroll timelines where supported and from cached geometry elsewhere.
Loading the example…
"use client";
import "@neshel-ui/animations/scroll.css";
import { ScrollProgressBar } from "@neshel-ui/animations/scroll";
import { useState } from "react";
export default function SP03Example() {
const [source, setSource] = useState<HTMLElement | null>(null);
return (
<div>
<ScrollProgressBar source={source} position="static" className="text-neshel-primary" />
<section
ref={setSource}
aria-label="Scrollable text"
tabIndex={0}
className="h-40 overflow-y-auto rounded-b-xl border border-neshel-border p-4"
>
{Array.from({ length: 12 }, (_, index) => (
<p key={index} className="py-1">
Paragraph {index + 1}
</p>
))}
</section>
</div>
);
}Options: ScrollProgressEffectOptions
ScrollProgressEffectOptions
| Prop | Type | Default | Description |
|---|---|---|---|
| driver | DriverPreference | — | "auto" (default): native scroll timeline when verified, else JS. |
| range | readonly [RangeInput, RangeInput] | — | Range of the effect's own timeline (ignored with timeline). |
| reducedMotion | ReducedMotion | — | — |
| scrollAxis | ScrollAxis | "block" | Scroll axis of the effect's own timeline (default "block"). |
| smooth | boolean | SpringOptions | SpringPreset | — | SP10 spring smoothing of the effect's own timeline. |
| source | Element | Window | null | — | Scroll container of the effect's own timeline (default: the root scroller). |
| timeline | ScrollProgress | — | A shared timeline (e.g. from useScrollScene()); otherwise the effect creates one. |
SP04 · Horizontal section
<HorizontalScroll> turns vertical scrolling into horizontal travel of a pinned track. layout can be "pinned", "stacked" or "scroll" (a native scroller, used in the example). Focus keeps items in view; under reduced motion it is stacked. Put something focusable in the items: the native scroller is not a tab stop by itself.
- Import
@neshel-ui/animations/scroll- API
HorizontalScroll- Stylesheet
@neshel-ui/animations/scroll.css- Reduced motion
static— the decoration or content stays still- Performance
- Transform and opacity, one write per frame through the shared scheduler; no layout work per frame.
Loading the example…
"use client";
import "@neshel-ui/animations/scroll.css";
import { HorizontalScroll } from "@neshel-ui/animations/scroll";
export default function SP04Example() {
return (
<HorizontalScroll label="Milestones" layout="scroll">
{["Idea", "Prototype", "Beta", "Launch", "Growth"].map((item) => (
<a
key={item}
href="#sp04"
className="rounded-xl border border-neshel-border bg-neshel-surface p-6 text-neshel-surface-foreground w-64"
>
{item}
</a>
))}
</HorizontalScroll>
);
}SP05 · Pinned scene
<ScrollScene> pins a stage for length viewport heights and exposes --neshel-scene-progress to everything inside. useScrollScene() gives the timeline to other effects, such as scene chapters.
- Import
@neshel-ui/animations/scroll- API
ScrollScene, pinnedScene- Stylesheet
@neshel-ui/animations/scroll.css- Reduced motion
static— the decoration or content stays still- Performance
- Writes one custom property, natively with scroll timelines where supported and from cached geometry elsewhere.
Loading the example…
"use client";
import "@neshel-ui/animations/scroll.css";
import { ScrollScene } from "@neshel-ui/animations/scroll";
export default function SP05Example() {
return (
<ScrollScene length={2} stageClassName="grid place-items-center rounded-xl bg-neshel-muted">
<div className="rounded-xl border border-neshel-border bg-neshel-surface p-6 text-neshel-surface-foreground">
<p>Pinned by CSS sticky while the page scrolls</p>
<span
aria-hidden="true"
className="mt-3 block h-2 origin-left bg-neshel-primary"
style={{ transform: "scaleX(var(--neshel-scene-progress, 0))" }}
/>
</div>
</ScrollScene>
);
}Options: PinnedSceneOptions
PinnedSceneOptions
| Prop | Type | Default | Description |
|---|---|---|---|
| driver | DriverPreference | — | "auto" (default): native scroll timeline when verified, else JS. |
| range | readonly [RangeInput, RangeInput] | — | Range of the effect's own timeline (ignored with timeline). |
| reducedMotion | ReducedMotion | — | — |
| scrollAxis | ScrollAxis | "block" | Scroll axis of the effect's own timeline (default "block"). |
| smooth | boolean | SpringOptions | SpringPreset | — | SP10 spring smoothing of the effect's own timeline. |
| source | Element | Window | null | — | Scroll container of the effect's own timeline (default: the root scroller). |
| timeline | ScrollProgress | — | A shared timeline (e.g. from useScrollScene()); otherwise the effect creates one. |
SP06 · Image parallax
<ParallaxImage> moves the first child inside a clipping frame by ±amount pixels and scales it just enough to cover the frame. The native image keeps its attributes.
- Import
@neshel-ui/animations/scroll- API
ParallaxImage, imageParallax- Stylesheet
@neshel-ui/animations/scroll.css- Reduced motion
static— the decoration or content stays still- Performance
- Transform and opacity, one write per frame through the shared scheduler; no layout work per frame.
Loading the example…
"use client";
import "@neshel-ui/animations/scroll.css";
import { ParallaxImage } from "@neshel-ui/animations/scroll";
import { picture } from "./picture";
export default function SP06Example() {
return (
<ParallaxImage amount={40} className="h-56 max-w-md rounded-xl">
<img
src={picture("Parallax", 20, 330)}
alt="Warm gradient"
width={640}
height={400}
className="h-full w-full object-cover"
/>
</ParallaxImage>
);
}Options: ImageParallaxOptions
ImageParallaxOptions
| Prop | Type | Default | Description |
|---|---|---|---|
| amount | number | — | Travel each way in px (0–400, default 48). The media is scaled to keep the frame covered. |
| frame | Element | — | The clipping frame (default: the element's parent). |
| range | readonly [RangeInput, RangeInput] | — | Range of the effect's own timeline (ignored with timeline). |
| reducedMotion | ReducedMotion | — | — |
| scrollAxis | ScrollAxis | "block" | Scroll axis of the effect's own timeline (default "block"). |
| smooth | boolean | SpringOptions | SpringPreset | — | SP10 spring smoothing of the effect's own timeline. |
| source | Element | Window | null | — | Scroll container of the effect's own timeline (default: the root scroller). |
| timeline | ScrollProgress | — | A shared timeline (e.g. from useScrollScene()); otherwise the effect creates one. |
SP07 · Zoom on scroll
zoomOnScroll scales the element between from (1) and to (1.2) over the chosen range. It composes with other transforms on the same element.
- Import
@neshel-ui/animations/scroll- API
zoomOnScroll, ScrollEffect- Stylesheet
- none needed
- Reduced motion
static— the decoration or content stays still- Performance
- Transform and opacity, one write per frame through the shared scheduler; no layout work per frame.
"use client";
import { ScrollEffect, type ZoomOnScrollOptions, zoomOnScroll } from "@neshel-ui/animations/scroll";
export default function SP07Example() {
return (
<ScrollEffect
preset={zoomOnScroll}
options={{ from: 0.8, to: 1 } satisfies ZoomOnScrollOptions}
className="rounded-xl border border-neshel-border bg-neshel-surface p-6 text-neshel-surface-foreground"
>
Grows with the scroll position
</ScrollEffect>
);
}Options: ZoomOnScrollOptions
ZoomOnScrollOptions
| Prop | Type | Default | Description |
|---|---|---|---|
| easing | Easing | EasingPreset | — | — |
| from | number | — | Scale at progress 0 (0.1–5, default 1). |
| range | readonly [RangeInput, RangeInput] | — | Range of the effect's own timeline (ignored with timeline). |
| reducedMotion | ReducedMotion | — | — |
| scrollAxis | ScrollAxis | "block" | Scroll axis of the effect's own timeline (default "block"). |
| smooth | boolean | SpringOptions | SpringPreset | — | SP10 spring smoothing of the effect's own timeline. |
| source | Element | Window | null | — | Scroll container of the effect's own timeline (default: the root scroller). |
| timeline | ScrollProgress | — | A shared timeline (e.g. from useScrollScene()); otherwise the effect creates one. |
| to | number | — | Scale at progress 1 (0.1–5, default 1.2). |
SP08 · Scroll colour shift
scrollColorShift mixes 2–8 stops into --neshel-scroll-color, or sets data-neshel-theme on a target with themes. Check the contrast of your text at every stop; under reduced motion the change is stepped.
- Import
@neshel-ui/animations/scroll- API
scrollColorShift, ScrollEffect- Stylesheet
- none needed
- Reduced motion
instant— the end state appears at once- Performance
- Repaints the element (colour, gradient, clip, mask, blur or stroke) while it runs; keep the area small.
"use client";
import {
type ScrollColorShiftOptions,
ScrollEffect,
scrollColorShift,
} from "@neshel-ui/animations/scroll";
export default function SP08Example() {
return (
<ScrollEffect
preset={scrollColorShift}
options={{ stops: ["#193767", "#7c2d12"] } satisfies ScrollColorShiftOptions}
className="rounded-xl p-8 text-white"
style={{ background: "var(--neshel-scroll-color, #193767)" }}
>
The background follows the scroll position
</ScrollEffect>
);
}Options: ScrollColorShiftOptions
ScrollColorShiftOptions
| Prop | Type | Default | Description |
|---|---|---|---|
| range | readonly [RangeInput, RangeInput] | — | Range of the effect's own timeline (ignored with timeline). |
| reducedMotion | ReducedMotion | — | — |
| scrollAxis | ScrollAxis | "block" | Scroll axis of the effect's own timeline (default "block"). |
| smooth | boolean | SpringOptions | SpringPreset | — | SP10 spring smoothing of the effect's own timeline. |
| source | Element | Window | null | — | Scroll container of the effect's own timeline (default: the root scroller). |
| space | "oklab" | "oklch" | "srgb" | "oklab" | Interpolation space of color-mix() (default "oklab"). |
| stops(required) | readonly string[] | — | Two or more CSS colours (at most 8). |
| themeTarget | Element | — | Element receiving data-neshel-theme (default: the element). |
| themes | readonly string[] | — | Optional theme names (one per stop) written to data-neshel-theme on themeTarget. |
| timeline | ScrollProgress | — | A shared timeline (e.g. from useScrollScene()); otherwise the effect creates one. |
SP09 · Sticky stack
<StickyStack> makes its children sticky cards that pile up; top and offset are CSS lengths and scale shrinks covered cards. Cards taller than the viewport cannot be read completely.
- Import
@neshel-ui/animations/scroll- API
StickyStack, stickyStack- Stylesheet
@neshel-ui/animations/scroll.css- Reduced motion
static— the decoration or content stays still- Performance
- Transform and opacity, one write per frame through the shared scheduler; no layout work per frame.
Loading the example…
"use client";
import "@neshel-ui/animations/scroll.css";
import { StickyStack } from "@neshel-ui/animations/scroll";
export default function SP09Example() {
return (
<StickyStack top="5rem" offset="1rem" className="grid gap-6">
{["First", "Second", "Third"].map((item) => (
<div
key={item}
className="rounded-xl border border-neshel-border bg-neshel-surface p-6 text-neshel-surface-foreground h-48"
>
{item}
</div>
))}
</StickyStack>
);
}Options: StickyStackOptions
StickyStackOptions
| Prop | Type | Default | Description |
|---|---|---|---|
| range | readonly [RangeInput, RangeInput] | — | Range of the effect's own timeline (ignored with timeline). |
| reducedMotion | ReducedMotion | — | — |
| scale | number | — | Scale removed from a fully covered card (0–0.5, default 0.05; 0 = CSS-only stacking). |
| scrollAxis | ScrollAxis | "block" | Scroll axis of the effect's own timeline (default "block"). |
| smooth | boolean | SpringOptions | SpringPreset | — | SP10 spring smoothing of the effect's own timeline. |
| source | Element | Window | null | — | Scroll container of the effect's own timeline (default: the root scroller). |
| timeline | ScrollProgress | — | A shared timeline (e.g. from useScrollScene()); otherwise the effect creates one. |
SP10 · Smooth scrub
The smooth option of <ScrollScene>, useScrollProgress and createScrollProgress passes progress through a spring. The page scroll itself is never smoothed; only what follows it is.
- Import
@neshel-ui/animations/scroll- API
createScrollProgress, useScrollProgress, ScrollScene- Stylesheet
- none needed
- Reduced motion
off— no motion at all- Performance
- Transform and opacity, one write per frame through the shared scheduler; no layout work per frame.
The same progress through a spring
"use client";
import { ScrollScene } from "@neshel-ui/animations/scroll";
export default function SP10Example() {
return (
<ScrollScene
length={2}
smooth
stageClassName="grid place-items-center rounded-xl bg-neshel-muted"
>
<div className="rounded-xl border border-neshel-border bg-neshel-surface p-6 text-neshel-surface-foreground">
<p>The same progress through a spring</p>
<span
aria-hidden="true"
className="mt-3 block h-2 origin-left bg-neshel-primary"
style={{ transform: "scaleX(var(--neshel-scene-progress, 0))" }}
/>
</div>
</ScrollScene>
);
}Options: ScrollProgressOptions
ScrollProgressOptions
| Prop | Type | Default | Description |
|---|---|---|---|
| axis | ScrollAxis | — | — |
| range | readonly [RangeInput, RangeInput] | — | — |
| reducedMotion | ReducedMotion | "user" | Reduced-motion policy for smoothing (default "user"). |
| smooth | boolean | SpringOptions | SpringPreset | — | SP10: spring-smoothed progress (true = prototype spring 90/20). |
| source | Element | Window | null | — | Scroll container; omitted, null or window → the root scroller. |
| subject | Element | null | — | Element whose view range is tracked; omit for the source's whole scroll range. |
SP11 · Velocity skew
velocitySkew leans the element with the scroll velocity, limited by max degrees, and springs back to zero. Keep it small: it is decorative and turns off under reduced motion.
- Import
@neshel-ui/animations/scroll- API
velocitySkew, ScrollEffect- Stylesheet
- none needed
- Reduced motion
off— no motion at all- Performance
- Transform and opacity, one write per frame through the shared scheduler; no layout work per frame.
"use client";
import { ScrollEffect, type VelocitySkewOptions, velocitySkew } from "@neshel-ui/animations/scroll";
export default function SP11Example() {
return (
<ScrollEffect
preset={velocitySkew}
options={{ max: 8 } satisfies VelocitySkewOptions}
className="rounded-xl border border-neshel-border bg-neshel-surface p-6 text-neshel-surface-foreground"
>
Scroll fast: I lean with the velocity and spring back.
</ScrollEffect>
);
}Options: VelocitySkewOptions
VelocitySkewOptions
| Prop | Type | Default | Description |
|---|---|---|---|
| axis | "x" | "y" | — | — |
| factor | number | — | Degrees per px/s (0–0.05, default 0.003). |
| max | number | — | Maximum skew in degrees (0–30, default 8). |
| reducedMotion | ReducedMotion | — | — |
| source | Element | Window | null | — | — |
| spring | SpringOptions | — | — |