Images & Media
The 10 effects M01–M10: purpose, API, options, examples, reduced motion and cost.
Experimental and not on npm
Media effects never write native media attributes (alt, srcset, sizes, loading, dimensions). An image is hidden only while it is still loading and is always shown on load, error, timeout, reduced motion or unmount, so a failure never leaves a hole. Slides that are not current are inert and stay mounted. Images that are not CORS-clean cannot be painted on a canvas; the effects that need one fall back to a fade.
M01 · Ken Burns
<KenBurns> moves a bounded camera over one image, from a from pose to a to pose (scale, x, y). It runs once by default and goes back and forth with repeat and yoyo; edges never show.
- Import
@neshel-ui/animations/media- API
KenBurns, useKenBurns, createKenBurns- Stylesheet
@neshel-ui/animations/media.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/media.css";
import { KenBurns, type ProgressControl } from "@neshel-ui/animations/media";
import { Button } from "@neshel-ui/components";
import { useRef } from "react";
import { picture } from "./picture";
export default function M01Example() {
const control = useRef<ProgressControl | null>(null);
return (
<div className="grid justify-items-start gap-3">
<KenBurns
controlRef={control}
to={{ scale: 1.25, x: 0.6, y: -0.4 }}
className="h-56 w-80 max-w-full rounded-xl"
>
<img src={picture("Ken Burns", 210, 260)} alt="Blue gradient" width={640} height={400} />
</KenBurns>
<Button variant="outline" onClick={() => control.current?.play()}>
Play again
</Button>
</div>
);
}Options: KenBurnsOptions
KenBurnsOptions
| Prop | Type | Default | Description |
|---|---|---|---|
| duration | number | — | ms (0–10000; default per effect). |
| easing | Easing | EasingPreset | — | — |
| from | CameraPose | { scale: 1.05, x: 0, y: 0 } | Start pose (default { scale: 1.05, x: 0, y: 0 }). |
| onComplete | (result: MotionResult) => void | — | — |
| progress | ProgressSource | — | Drive from a 0–1 source instead of the own clock. |
| reducedMotion | ReducedMotion | — | — |
| repeat | number | — | Extra runs (0–1000 or Infinity, explicit; default 0). Paused off-screen and on hidden pages. |
| to | CameraPose | { scale: 1.18, x: 0.4, y: -0.3 } | End pose (default { scale: 1.18, x: 0.4, y: -0.3 }). |
| trigger | ProgressTrigger | "visible" | Default "visible" (once); ignored with progress. |
| yoyo | boolean | true | Alternate direction between runs (default true). |
M02 · Blur-up loading
<BlurUpImage> shows a placeholder (a tiny image, gradient or colour) with blur until the native image loads. An already loaded image appears at once unless you pass replay, as the example does.
- Import
@neshel-ui/animations/media- API
BlurUpImage, createBlurUp- Stylesheet
@neshel-ui/animations/media.css- 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.
Loading the example…
"use client";
import "@neshel-ui/animations/media.css";
import { BlurUpImage } from "@neshel-ui/animations/media";
import { Button } from "@neshel-ui/components";
import { useState } from "react";
import { picture } from "./picture";
export default function M02Example() {
const [run, setRun] = useState(0);
return (
<div className="grid justify-items-start gap-3">
<BlurUpImage
key={run}
replay
src={picture("Loaded", 20, 330)}
alt="Warm gradient"
width={320}
height={200}
placeholder="linear-gradient(135deg, #7c2d12, #831843)"
/>
<Button variant="outline" onClick={() => setRun(run + 1)}>
Replay
</Button>
</div>
);
}Options: BlurUpOptions
BlurUpOptions
| Prop | Type | Default | Description |
|---|---|---|---|
| blur | number | — | Placeholder blur in px (0–40, default 16). |
| duration | number | — | ms (0–10000; default per effect). |
| easing | Easing | EasingPreset | — | — |
| image | HTMLImageElement | — | The image (default: the frame's first img). |
| onStateChange | (state: MediaRevealState) => void | — | — |
| placeholder | string | — | Placeholder: a tiny image URL/data URI, a CSS gradient or a colour (default a neutral tint). |
| reducedMotion | ReducedMotion | — | — |
| replay | boolean | — | Animate an image that is already loaded at attach time (default false: shown at once). |
| revealTimeout | number | — | ms after which a still-loading image is revealed anyway (500–60000, default 8000). |
M03 · Reveal on load
<LoadReveal> uncovers an image when it loads with a shape: inset, circle or wipe. revealTimeout (8 s) shows it anyway if loading never finishes.
- Import
@neshel-ui/animations/media- API
LoadReveal, createLoadReveal- 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.
Loading the example…
"use client";
import { LoadReveal } from "@neshel-ui/animations/media";
import { Button } from "@neshel-ui/components";
import { useState } from "react";
import { picture } from "./picture";
export default function M03Example() {
const [run, setRun] = useState(0);
return (
<div className="grid justify-items-start gap-3">
<LoadReveal key={run} shape="circle" replay>
<img src={picture("Revealed", 120, 180)} alt="Green gradient" width={320} height={200} />
</LoadReveal>
<Button variant="outline" onClick={() => setRun(run + 1)}>
Replay
</Button>
</div>
);
}Options: LoadRevealOptions
LoadRevealOptions
| Prop | Type | Default | Description |
|---|---|---|---|
| direction | "up" | "down" | "left" | "right" | up | Edge the reveal travels toward (default up for inset, right for wipe). |
| duration | number | — | ms (0–10000; default per effect). |
| easing | Easing | EasingPreset | — | — |
| onStateChange | (state: MediaRevealState) => void | — | — |
| reducedMotion | ReducedMotion | — | — |
| replay | boolean | — | Animate an image that is already loaded at attach time (default false: shown at once). |
| revealTimeout | number | — | ms after which a still-loading image is revealed anyway (500–60000, default 8000). |
| shape | "inset" | "circle" | "wipe" | — | inset (edge wipe, default), circle (from the centre) or wipe (horizontal). |
M04 · Compare slider
<CompareSlider> compares two elements with a native range input: keyboard, tap and drag work, and jumps adds buttons. label is required, and both images need their own alternative text.
- Import
@neshel-ui/animations/media- API
CompareSlider, createCompareSlider- Stylesheet
@neshel-ui/animations/media.css- Reduced motion
n/a— nothing moves by itself, so nothing changes- Performance
- Repaints the element (colour, gradient, clip, mask, blur or stroke) while it runs; keep the area small.
Loading the example…
"use client";
import "@neshel-ui/animations/media.css";
import { CompareSlider } from "@neshel-ui/animations/media";
import { picture } from "./picture";
export default function M04Example() {
return (
<CompareSlider
label="Compare the edit"
before={
<img
src={picture("Before", 210, 260)}
alt="Before: cool tones"
className="h-full w-full object-cover"
/>
}
after={
<img
src={picture("After", 20, 330)}
alt="After: warm tones"
className="h-full w-full object-cover"
/>
}
jumps={{ before: "Show before", after: "Show after" }}
className="h-56 w-80 max-w-full"
/>
);
}Options: CompareSliderOptions
CompareSliderOptions
| Prop | Type | Default | Description |
|---|---|---|---|
| onValueChange | (value: number) => void | — | — |
| orientation | "horizontal" | "vertical" | — | — |
| step | number | — | Keyboard step (0.1–25, default 1). |
| value | number | 50 | 0–100 (default 50): share of the before image. |
| valueText | (value: number) => string | "N% before, M% after" | Value text for assistive technology (default "N% before, M% after"). |
M05 · Duotone
<Duotone> maps the colours of an element to shadow and highlight through an SVG filter; amount blends with the original and the control plays it forwards or backwards.
- Import
@neshel-ui/animations/media- API
Duotone, createDuotone- Stylesheet
- none needed
- Reduced motion
instant— the end state appears at once- Performance
- Uses a filter over the whole area, which is expensive on large surfaces; use it on small or static regions.
Loading the example…
"use client";
import { Duotone, type ProgressControl } from "@neshel-ui/animations/media";
import { Button } from "@neshel-ui/components";
import { useRef } from "react";
import { picture } from "./picture";
export default function M05Example() {
const control = useRef<ProgressControl | null>(null);
return (
<div className="grid justify-items-start gap-3">
<Duotone controlRef={control} trigger="manual">
<img src={picture("Duotone", 120, 200)} alt="Green gradient" width={320} height={200} />
</Duotone>
<div className="flex gap-2">
<Button variant="outline" onClick={() => control.current?.play()}>
Duotone
</Button>
<Button variant="outline" onClick={() => control.current?.reverse()}>
Original
</Button>
</div>
</div>
);
}Options: DuotoneOptions
DuotoneOptions
| Prop | Type | Default | Description |
|---|---|---|---|
| amount | number | 1 | Final amount of duotone 0–1 (default 1). |
| duration | number | — | ms (0–10000; default per effect). |
| easing | Easing | EasingPreset | — | — |
| highlight | string | #f2c14e | Colour of the highlights (default #f2c14e). |
| onComplete | (result: MotionResult) => void | — | — |
| progress | ProgressSource | — | Drive from a 0–1 source instead of the own clock. |
| reducedMotion | ReducedMotion | — | — |
| shadow | string | #1b1f3a | Colour of the shadows (default #1b1f3a). Hex #rgb/#rrggbb or rgb(r g b). |
| trigger | ProgressTrigger | "visible" | Default "visible" (once); ignored with progress. |
M06 · Video scrub
useVideoScrub maps a 0–1 progress source to the time of a video. It never calls play(), keeps at most one seek in flight and waits for the metadata. Encode with frequent keyframes for smooth scrubbing.
- Import
@neshel-ui/animations/media- API
useVideoScrub, createVideoScrub- Stylesheet
- none needed
- Reduced motion
static— the decoration or content stays still- Performance
- At most one video seek in flight; the newest target wins. Quality depends on the keyframes of the file.
"use client";
import { motionValue } from "@neshel-ui/animations/core";
import { useVideoScrub } from "@neshel-ui/animations/media";
import { useMemo, useRef } from "react";
const base = process.env.NESHEL_DOCS_BASE_PATH ?? "";
export default function M06Example() {
const video = useRef<HTMLVideoElement>(null);
const progress = useMemo(() => motionValue(0), []);
useVideoScrub(video, { progress });
return (
<div className="grid justify-items-start gap-3">
<video
ref={video}
muted
playsInline
preload="auto"
width={320}
height={180}
aria-label="Sample clip"
>
<source src={`${base}/animations/scrub.webm`} type="video/webm" />
<source src={`${base}/animations/scrub.mp4`} type="video/mp4" />
</video>
<label className="grid gap-1">
Position
<input
type="range"
min={0}
max={100}
defaultValue={0}
onInput={(event) => progress.set(Number(event.currentTarget.value) / 100)}
/>
</label>
</div>
);
}Options: VideoScrubOptions
VideoScrubOptions
| Prop | Type | Default | Description |
|---|---|---|---|
| precision | "exact" | "fast" | — | exact (default) or fast (keyframe seeks via fastSeek where available). |
| progress | ProgressSource | — | 0–1 source (required unless you call drive() later). |
| range | readonly [number, number] | — | Time range in s mapped to 0–1 (default the whole duration). |
| reducedMotion | ReducedMotion | — | — |
| restTime | number | — | s shown under reduced motion (default: the current time). |
| restore | boolean | false | Restore the original currentTime on destroy (default false). |
| tolerance | number | — | s; smaller differences are not sought (0–1, default 1/60). |
M07 · Lightbox zoom
<Lightbox> opens a native modal <dialog> that grows from the thumbnail. Escape, the backdrop and the close button close it, focus returns to the opener, and label names it.
- Import
@neshel-ui/animations/media- API
Lightbox, createLightboxZoom- Stylesheet
@neshel-ui/animations/media.css- Reduced motion
fade— opacity only, no travel- Performance
- Reads layout boxes once before and once after the change, then animates transforms (FLIP).
Loading the example…
"use client";
import "@neshel-ui/animations/media.css";
import { Lightbox } from "@neshel-ui/animations/media";
import { picture } from "./picture";
export default function M07Example() {
return (
<Lightbox
label="Violet gradient, enlarged"
thumbnail={
<img
src={picture("Open", 280, 330)}
alt="Open the violet gradient"
width={192}
height={120}
/>
}
>
<img src={picture("Large", 280, 330)} alt="Violet gradient" width={640} height={400} />
</Lightbox>
);
}Options: LightboxZoomOptions
LightboxZoomOptions
| Prop | Type | Default | Description |
|---|---|---|---|
| dialog(required) | HTMLDialogElement | — | — |
| duration | number | — | ms of the zoom (0–2000, default 380). |
| getThumbnail(required) | () => Element | null | — | The thumbnail to zoom from/to (measured at open and close). |
| image(required) | HTMLElement | — | The large image (or any element) that zooms. |
| onOpenChange | (open: boolean) => void | — | — |
| reducedMotion | ReducedMotion | — | — |
M08 · Gallery cross-fade
<Crossfade> shows the child at index and fades between them. interval rotates automatically (at least 2 s) and pauses on hover, focus and hidden pages; add your own pause control if you use it.
- Import
@neshel-ui/animations/media- API
Crossfade, createCrossfade- Stylesheet
@neshel-ui/animations/media.css- Reduced motion
fade— opacity only, no travel- 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/media.css";
import { Crossfade } from "@neshel-ui/animations/media";
import { Button } from "@neshel-ui/components";
import { useState } from "react";
import { picture } from "./picture";
export default function M08Example() {
const [index, setIndex] = useState(0);
return (
<div className="grid justify-items-start gap-3">
<Crossfade index={index} className="h-52 w-80 max-w-full">
<img src={picture("One", 210, 260)} alt="Slide one" />
<img src={picture("Two", 20, 330)} alt="Slide two" />
</Crossfade>
<Button variant="outline" onClick={() => setIndex(1 - index)}>
Next slide
</Button>
</div>
);
}Options: CrossfadeOptions
CrossfadeOptions
| Prop | Type | Default | Description |
|---|---|---|---|
| duration | number | — | ms (0–10000; default per effect). |
| easing | Easing | EasingPreset | — | — |
| index | number | 0 | Initial slide (default 0). |
| interval | number | — | Autoplay interval in ms (≥ 2000; none by default). Paused on hover, focus inside and hidden pages. |
| onIndexChange | (index: number) => void | — | — |
| reducedMotion | ReducedMotion | — | — |
M09 · Pixel dissolve
<PixelDissolve> replaces one image with another in cell-sized blocks in a seeded order, painted on a canvas that is released afterwards. Large areas are limited by maxCells; without a clean canvas it fades.
- Import
@neshel-ui/animations/media- API
PixelDissolve, createPixelDissolve- Stylesheet
@neshel-ui/animations/media.css- Reduced motion
fade— opacity only, no travel- Performance
- Draws on a decorative Canvas 2D surface with a capped pixel ratio; the surface is released when it is not needed.
Loading the example…
"use client";
import "@neshel-ui/animations/media.css";
import { PixelDissolve } from "@neshel-ui/animations/media";
import { Button } from "@neshel-ui/components";
import { useState } from "react";
import { picture } from "./picture";
export default function M09Example() {
const [index, setIndex] = useState(0);
return (
<div className="grid justify-items-start gap-3">
<PixelDissolve index={index} cell={14} className="h-52 w-80 max-w-full">
<img src={picture("A", 210, 260)} alt="Blue gradient" />
<img src={picture("B", 20, 330)} alt="Warm gradient" />
</PixelDissolve>
<Button variant="outline" onClick={() => setIndex(1 - index)}>
Dissolve
</Button>
</div>
);
}Options: PixelDissolveOptions
PixelDissolveOptions
| Prop | Type | Default | Description |
|---|---|---|---|
| cell | number | — | Cell size in CSS px (4–64, default 16); enlarged when the grid would exceed maxCells. |
| duration | number | — | ms (0–10000; default per effect). |
| easing | Easing | EasingPreset | — | — |
| index | number | 0 | Initial slide (default 0). |
| maxCells | number | — | Upper bound of cells (64–4096, default 4096). |
| maxDpr | number | — | Canvas DPR cap (1–3, default 2). |
| onIndexChange | (index: number) => void | — | — |
| reducedMotion | ReducedMotion | — | — |
| seed | number | 1 | Order seed (default 1). |
M10 · Hover pan
<HoverPan> enlarges an image inside its frame (scale 1.4) and pans with the pointer. keyboard makes the frame focusable for the arrow keys and then requires a label.
- Import
@neshel-ui/animations/media- API
HoverPan, createHoverPan- Stylesheet
@neshel-ui/animations/media.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/media.css";
import { HoverPan } from "@neshel-ui/animations/media";
import { picture } from "./picture";
export default function M10Example() {
return (
<HoverPan
keyboard
label="Pan the detail with the arrow keys"
className="h-52 w-80 max-w-full rounded-xl"
>
<img src={picture("Pan", 30, 300)} alt="Gradient detail" width={640} height={400} />
</HoverPan>
);
}Options: HoverPanOptions
HoverPanOptions
| Prop | Type | Default | Description |
|---|---|---|---|
| keyboard | boolean | — | Focusable frame with arrow-key panning (for images whose detail is information; needs a name). |
| media | Element | — | The element that moves (default: the frame's first element child). |
| pointerTypes | readonly ("mouse" | "pen" | "touch")[] | — | Pointer types that pan (default mouse and pen; touch scrolls the page). |
| reducedMotion | ReducedMotion | — | — |
| scale | number | 1.4 | Zoom while hovering 1.05–3 (default 1.4). |
| spring | SpringOptions | — | — |
| step | number | — | Keyboard step as a fraction of the pan range (0.02–0.5, default 0.1). |