Skip to Content
Neshel-UI
Animations (experimental)Effects

Images & Media

The 10 effects M01–M10: purpose, API, options, examples, reduced motion and cost.

Experimental and not on npm

@neshel-ui/animations is a private package (0.0.0). It cannot be installed, and its API may change before a first publication. These pages document what exists in the repository.

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.
Preview: M01
Preview theme: M01

Loading the example…

m01.tsx
"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

KenBurnsOptions
PropTypeDefaultDescription
durationnumber—ms (0–10000; default per effect).
easingEasing | EasingPreset——
fromCameraPose{ scale: 1.05, x: 0, y: 0 }Start pose (default { scale: 1.05, x: 0, y: 0 }).
onComplete(result: MotionResult) => void——
progressProgressSource—Drive from a 0–1 source instead of the own clock.
reducedMotionReducedMotion——
repeatnumber—Extra runs (0–1000 or Infinity, explicit; default 0). Paused off-screen and on hidden pages.
toCameraPose{ scale: 1.18, x: 0.4, y: -0.3 }End pose (default { scale: 1.18, x: 0.4, y: -0.3 }).
triggerProgressTrigger"visible"Default "visible" (once); ignored with progress.
yoyobooleantrueAlternate 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.
Preview: M02
Preview theme: M02

Loading the example…

m02.tsx
"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

BlurUpOptions
PropTypeDefaultDescription
blurnumber—Placeholder blur in px (0–40, default 16).
durationnumber—ms (0–10000; default per effect).
easingEasing | EasingPreset——
imageHTMLImageElement—The image (default: the frame's first img).
onStateChange(state: MediaRevealState) => void——
placeholderstring—Placeholder: a tiny image URL/data URI, a CSS gradient or a colour (default a neutral tint).
reducedMotionReducedMotion——
replayboolean—Animate an image that is already loaded at attach time (default false: shown at once).
revealTimeoutnumber—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.
Preview: M03
Preview theme: M03

Loading the example…

m03.tsx
"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

LoadRevealOptions
PropTypeDefaultDescription
direction"up" | "down" | "left" | "right"upEdge the reveal travels toward (default up for inset, right for wipe).
durationnumber—ms (0–10000; default per effect).
easingEasing | EasingPreset——
onStateChange(state: MediaRevealState) => void——
reducedMotionReducedMotion——
replayboolean—Animate an image that is already loaded at attach time (default false: shown at once).
revealTimeoutnumber—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.
Preview: M04
Preview theme: M04

Loading the example…

m04.tsx
"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

CompareSliderOptions
PropTypeDefaultDescription
onValueChange(value: number) => void——
orientation"horizontal" | "vertical"——
stepnumber—Keyboard step (0.1–25, default 1).
valuenumber500–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.
Preview: M05
Preview theme: M05

Loading the example…

m05.tsx
"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

DuotoneOptions
PropTypeDefaultDescription
amountnumber1Final amount of duotone 0–1 (default 1).
durationnumber—ms (0–10000; default per effect).
easingEasing | EasingPreset——
highlightstring#f2c14eColour of the highlights (default #f2c14e).
onComplete(result: MotionResult) => void——
progressProgressSource—Drive from a 0–1 source instead of the own clock.
reducedMotionReducedMotion——
shadowstring#1b1f3aColour of the shadows (default #1b1f3a). Hex #rgb/#rrggbb or rgb(r g b).
triggerProgressTrigger"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.
Preview: M06
Preview theme: M06
m06.tsx
"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

VideoScrubOptions
PropTypeDefaultDescription
precision"exact" | "fast"—exact (default) or fast (keyframe seeks via fastSeek where available).
progressProgressSource—0–1 source (required unless you call drive() later).
rangereadonly [number, number]—Time range in s mapped to 0–1 (default the whole duration).
reducedMotionReducedMotion——
restTimenumber—s shown under reduced motion (default: the current time).
restorebooleanfalseRestore the original currentTime on destroy (default false).
tolerancenumber—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).
Preview: M07
Preview theme: M07

Loading the example…

m07.tsx
"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

LightboxZoomOptions
PropTypeDefaultDescription
dialog(required)HTMLDialogElement——
durationnumber—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——
reducedMotionReducedMotion——

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.
Preview: M08
Preview theme: M08

Loading the example…

m08.tsx
"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

CrossfadeOptions
PropTypeDefaultDescription
durationnumber—ms (0–10000; default per effect).
easingEasing | EasingPreset——
indexnumber0Initial slide (default 0).
intervalnumber—Autoplay interval in ms (≥ 2000; none by default). Paused on hover, focus inside and hidden pages.
onIndexChange(index: number) => void——
reducedMotionReducedMotion——

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.
Preview: M09
Preview theme: M09

Loading the example…

m09.tsx
"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

PixelDissolveOptions
PropTypeDefaultDescription
cellnumber—Cell size in CSS px (4–64, default 16); enlarged when the grid would exceed maxCells.
durationnumber—ms (0–10000; default per effect).
easingEasing | EasingPreset——
indexnumber0Initial slide (default 0).
maxCellsnumber—Upper bound of cells (64–4096, default 4096).
maxDprnumber—Canvas DPR cap (1–3, default 2).
onIndexChange(index: number) => void——
reducedMotionReducedMotion——
seednumber1Order 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.
Preview: M10
Preview theme: M10

Loading the example…

m10.tsx
"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

HoverPanOptions
PropTypeDefaultDescription
keyboardboolean—Focusable frame with arrow-key panning (for images whose detail is information; needs a name).
mediaElement—The element that moves (default: the frame's first element child).
pointerTypesreadonly ("mouse" | "pen" | "touch")[]—Pointer types that pan (default mouse and pen; touch scrolls the page).
reducedMotionReducedMotion——
scalenumber1.4Zoom while hovering 1.05–3 (default 1.4).
springSpringOptions——
stepnumber—Keyboard step as a fraction of the pan range (0.02–0.5, default 0.1).
Edit on GitHub

On this page