Skip to Content
Neshel-UI
Animations (experimental)Effects

Advanced 3D & Distortion

The 11 effects D01–D11: 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.

Seven effects use CSS 3D through the motion host (./advanced, which never loads WebGL); four use an optional WebGL2 layer (./gpu). Hidden faces, panels and items are inert and aria-hidden, so nothing behind the perspective can be focused. With WebGL the native image stays in the DOM and comes back on failure, context loss, reduced motion and unmount; HTML is never turned into a texture, and images and maps must be CORS-clean.

D01 · Card flip

<CardFlip> turns between front and back. Elements with data-neshel-flip-toggle turn it, focus moves to the visible face, and flipped with onFlippedChange controls it. Under reduced motion the faces fade.

Import
@neshel-ui/animations/advanced
API
CardFlip, createCardFlip
Stylesheet
@neshel-ui/animations/advanced.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: D01
Preview theme: D01

Loading the example…

d01.tsx
"use client";
import "@neshel-ui/animations/advanced.css";
import { CardFlip } from "@neshel-ui/animations/advanced";

const face =
  "grid h-full w-full content-between rounded-xl bg-neshel-primary p-4 text-neshel-primary-foreground";

export default function D01Example() {
  return (
    <CardFlip
      className="h-40 w-64"
      front={
        <div className={face}>
          <strong>Front</strong>
          <button type="button" data-neshel-flip-toggle>
            Show details
          </button>
        </div>
      }
      back={
        <div className={face}>
          <strong>Details</strong>
          <button type="button" data-neshel-flip-toggle>
            Back
          </button>
        </div>
      }
    />
  );
}
Options: CardFlipOptions

CardFlipOptions

CardFlipOptions
PropTypeDefaultDescription
axis"y" | "x"——
backHTMLElement——
direction1 | -1——
flippedbooleanfalseStart on the back (default false).
frontHTMLElement—Faces (default: the inner element's first two element children).
innerHTMLElement—The rotating element (default: the root's first element child).
onFlip(side: FlipSide) => void—The visible face changed (the rotation crossed 90°).
onToggle(side: FlipSide) => void—A toggle (in-face control or toggle()) changed the intended side — the user's intent, before any motion.
perspectivenumber1200px 200–4000 (default 1200).
reducedEffect"fade" | "instant"—Under reduced motion: cross-fade (default) or jump.
reducedMotionReducedMotion——
springSpringOptions——
toggleSelectorstring | false—Elements inside the faces that toggle on click (native buttons); false disables.

D02 · Cube rotation

<CubeRotate> rotates between its children as panels of a cube; go, next and previous on the control, or index. Only the active panel is interactive, and the faces never leave the panel box.

Import
@neshel-ui/animations/advanced
API
CubeRotate, createCubeRotate
Stylesheet
@neshel-ui/animations/advanced.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: D02
Preview theme: D02

Loading the example…

d02.tsx
"use client";
import "@neshel-ui/animations/advanced.css";
import { type CubeControl, CubeRotate } from "@neshel-ui/animations/advanced";
import { Button } from "@neshel-ui/components";
import { useRef } from "react";

export default function D02Example() {
  const cube = useRef<CubeControl | null>(null);
  return (
    <div className="grid justify-items-start gap-3">
      <CubeRotate controlRef={cube} className="h-36 w-56">
        {["One", "Two", "Three"].map((panel) => (
          <section
            key={panel}
            aria-label={`Panel ${panel}`}
            className="h-full w-full rounded-xl bg-neshel-primary p-4 text-neshel-primary-foreground"
          >
            Panel {panel}
          </section>
        ))}
      </CubeRotate>
      <div className="flex gap-2">
        <Button variant="outline" onClick={() => cube.current?.previous()}>
          Previous
        </Button>
        <Button variant="outline" onClick={() => cube.current?.next()}>
          Next
        </Button>
      </div>
    </div>
  );
}
Options: CubeRotateOptions

CubeRotateOptions

CubeRotateOptions
PropTypeDefaultDescription
axisAxis3D——
durationnumber700ms 0–10000 (default 700).
easingEasing | EasingPreset——
indexnumber0Initial panel (default 0).
loopbooleantrueWrap around at the ends (default true).
onChange(index: number) => void——
perspectivenumber1600px 200–6000 (default 1600).
reducedMotionReducedMotion——

D03 · Ring carousel

<RingCarousel> arranges its children on a ring. Arrow keys, Home, End and dragging move it, only the front item is focusable, and a polite region announces the slide. label is required.

Import
@neshel-ui/animations/advanced
API
RingCarousel, createRingCarousel
Stylesheet
@neshel-ui/animations/advanced.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: D03
Preview theme: D03

Loading the example…

d03.tsx
"use client";
import "@neshel-ui/animations/advanced.css";
import { RingCarousel, type RingControl } from "@neshel-ui/animations/advanced";
import { Button } from "@neshel-ui/components";
import { useRef } from "react";

export default function D03Example() {
  const ring = useRef<RingControl | null>(null);
  return (
    <div className="grid gap-3">
      <RingCarousel
        label="Destinations"
        radius={240}
        controlRef={ring}
        className="h-48 w-full max-w-lg"
      >
        {["Lisbon", "Kyoto", "Quito", "Oslo", "Cusco"].map((city) => (
          <article
            key={city}
            className="h-28 w-36 rounded-xl bg-neshel-primary p-4 text-neshel-primary-foreground"
          >
            {city}
          </article>
        ))}
      </RingCarousel>
      <div className="flex gap-2">
        <Button variant="outline" onClick={() => ring.current?.previous()}>
          Previous
        </Button>
        <Button variant="outline" onClick={() => ring.current?.next()}>
          Next
        </Button>
      </div>
    </div>
  );
}
Options: RingCarouselOptions

RingCarouselOptions

RingCarouselOptions
PropTypeDefaultDescription
announce(index: number, count: number) => string"Slide n of N"Text of the live announcement (default "Slide n of N").
dragboolean——
gapnumber—px 0–400 between items (auto radius; default 24).
indexnumber——
keyboardboolean——
labelstring—Accessible name of the carousel (required unless the root is labelled).
onChange(index: number) => void——
perspectivenumber1400px 200–6000 (default 1400).
radius"auto" | number—"auto" (from the item width) or px 50–4000.
reducedMotionReducedMotion——
springSpringOptions——

D04 · Page curl

<PageCurl> peels a raster front (an image or a canvas) over live under content with a WebGL mesh. driver="css" turns live HTML as a rigid page, and it is also the fallback without WebGL2.

Import
@neshel-ui/animations/gpu
API
PageCurl, createPageCurl
Stylesheet
@neshel-ui/animations/gpu.css
Reduced motion
instant — the end state appears at once
Performance
Uses a WebGL2 context from a page budget and draws only when something changes; the original content is the fallback.
Preview: D04
Preview theme: D04

Loading the example…

d04.tsx
"use client";
import "@neshel-ui/animations/gpu.css";
import { PageCurl, type PageCurlControl } from "@neshel-ui/animations/gpu";
import { Button } from "@neshel-ui/components";
import { useRef } from "react";
import { picture } from "./picture";

export default function D04Example() {
  const curl = useRef<PageCurlControl | null>(null);
  return (
    <div className="grid justify-items-start gap-3">
      <PageCurl
        controlRef={curl}
        className="w-80 max-w-full rounded-xl"
        front={<img src={picture("Page one", 210, 260)} alt="Page one" width={640} height={400} />}
        under={<div className="p-6">Page two, live HTML underneath</div>}
      />
      <div className="flex gap-2">
        <Button variant="outline" onClick={() => curl.current?.play()}>
          Turn
        </Button>
        <Button variant="outline" onClick={() => curl.current?.reverse()}>
          Back
        </Button>
      </div>
    </div>
  );
}
Options: PageCurlOptions

PageCurlOptions

PageCurlOptions
PropTypeDefaultDescription
backstring#f1f5f9CSS colour of the page's reverse (default #f1f5f9).
cornerCorner——
driver"auto" | "gpu" | "css"—"auto" (GPU, CSS fallback), "gpu" (static without WebGL2) or "css" (rigid turn; live HTML).
durationnumber—ms (0–10000; default per effect).
easingEasing | EasingPreset——
frontHTMLElement—The page that turns (GPU: <img>/<canvas>; CSS: any element; default: the frame's first child).
maxDprnumber——
mesh"small" | "medium" | "large" | { columns: number; rows: number; }—"small" 16×12, "medium" 32×24, "large" 64×48 or { columns, rows } ≤ 128×96.
onComplete(result: MotionResult) => void——
progressProgressSource—Drive from a 0–1 source instead of the own clock.
radiusnumber0.1Curl radius as a fraction of the diagonal 0.02–0.4 (default 0.1).
reducedMotionReducedMotion——
shadingnumber0.60–1 (default 0.6).
trigger"manual" | "mount"—"manual" (default) or "mount".
underHTMLElement—The page revealed underneath (default: the frame's second child, optional).

D05 · Corner recede

<CornerRecede> folds the corner under the pointer away like paper: size, angle, corners; reverse lifts it. The flap is an inert copy without ids; use flap="plain" for content that cannot be copied.

Import
@neshel-ui/animations/advanced
API
CornerRecede, createCornerRecede
Stylesheet
@neshel-ui/animations/advanced.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: D05
Preview theme: D05

The corner under the pointer folds away.

Read more
d05.tsx
"use client";
import "@neshel-ui/animations/advanced.css";
import { CornerRecede } from "@neshel-ui/animations/advanced";

export default function D05Example() {
  return (
    <CornerRecede className="h-40 w-64">
      <div className="h-full w-full rounded-xl bg-neshel-primary p-4 text-neshel-primary-foreground">
        <p>The corner under the pointer folds away.</p>
        <a href="#d05" className="underline">
          Read more
        </a>
      </div>
    </CornerRecede>
  );
}
Options: CornerRecedeOptions

CornerRecedeOptions

CornerRecedeOptions
PropTypeDefaultDescription
anglenumber60Maximum fold angle, deg 10–85 (default 60).
cornersreadonly Corner[]—Corners that may fold (default all four).
flap"clone" | "plain""clone""clone": inert ID-free copy of the surface; "plain": a surface-coloured triangle (default "clone").
focusCornerCorner | false"top-right"Corner folded at 35 % while focus inside is :focus-visible; false disables (default "top-right").
perspectivenumber900px 300–3000 perspective of the flap (default 900).
pointerTypesreadonly ("mouse" | "pen" | "touch")[]——
reducedMotionReducedMotion——
reversebooleanfalseLift the corner toward the viewer instead of receding (default false).
shadenumber0.3Flap darkening 0–0.6 (default 0.3).
sizenumber0.35Fold leg as a fraction of the shorter side 0.1–0.6 (default 0.35).
springSpringOptions——
surfaceHTMLElement—The live content element that is clipped (default: the root's first element child).
thresholdnumber0.3Neutral zone around the centre 0–0.9 (default 0.3).

D06 · Liquid ripple

<Ripple> sends damped waves through an image from each press, or from impact(x, y) on the control: amplitude, frequency, damping. It draws nothing once the energy is gone and is off under reduced motion.

Import
@neshel-ui/animations/gpu
API
Ripple, createRipple
Stylesheet
@neshel-ui/animations/gpu.css
Reduced motion
off — no motion at all
Performance
Uses a WebGL2 context from a page budget and draws only when something changes; the original content is the fallback.
Preview: D06
Preview theme: D06

Loading the example…

d06.tsx
"use client";
import "@neshel-ui/animations/gpu.css";
import { Ripple, type RippleControl } from "@neshel-ui/animations/gpu";
import { Button } from "@neshel-ui/components";
import { useRef } from "react";
import { picture } from "./picture";

export default function D06Example() {
  const ripple = useRef<RippleControl | null>(null);
  return (
    <div className="grid justify-items-start gap-3">
      <Ripple controlRef={ripple} className="w-80 max-w-full rounded-xl">
        <img src={picture("Water", 190, 230)} alt="Blue grid" width={640} height={400} />
      </Ripple>
      <Button variant="outline" onClick={() => ripple.current?.impact(0.5, 0.5)}>
        Drop at the centre
      </Button>
    </div>
  );
}
Options: RippleOptions

RippleOptions

RippleOptions
PropTypeDefaultDescription
amplitudenumber—0–1 (≤ 0.03 UV; default 0.5).
dampingnumber2.50.5–6 per second (default 2.5).
durationnumber2400ms of the seek/drive timeline 200–10000 (default 2400).
frequencynumber10.5–4 (default 1).
imageHTMLImageElement | HTMLCanvasElement—The raster source (default: the frame's first img/canvas).
maxDprnumber——
maxImpactsnumber41–8 simultaneous impacts (default 4).
reducedMotionReducedMotion——
seednumber1Integer seed of the seek/drive pattern (default 1).
speednumber0.450.1–1.5 UV per second (default 0.45).
trigger"pointer" | "hover" | "manual"——

D07 · Glitch

<Glitch> plays a short burst on hover and focus, or with play(). rate is capped at three changes per second to stay below the flash threshold, the text exists once, and it is off under reduced motion.

Import
@neshel-ui/animations/advanced
API
Glitch, createGlitch
Stylesheet
@neshel-ui/animations/advanced.css
Reduced motion
off — no motion at all
Performance
Repaints the element (colour, gradient, clip, mask, blur or stroke) while it runs; keep the area small.
Preview: D07
Preview theme: D07

NESHEL SIGNAL

d07.tsx
"use client";
import "@neshel-ui/animations/advanced.css";
import { Glitch, type GlitchControl } from "@neshel-ui/animations/advanced";
import { Button } from "@neshel-ui/components";
import { useRef } from "react";

export default function D07Example() {
  const glitch = useRef<GlitchControl | null>(null);
  return (
    <div className="grid justify-items-start gap-3">
      <p className="text-3xl font-bold">
        <Glitch controlRef={glitch}>NESHEL SIGNAL</Glitch>
      </p>
      <Button variant="outline" onClick={() => glitch.current?.play()}>
        Play a burst
      </Button>
    </div>
  );
}
Options: GlitchOptions

GlitchOptions

GlitchOptions
PropTypeDefaultDescription
colorsreadonly [string, string]—Two CSS colours of the channel layers.
durationnumber600Burst length ms 100–2000 (default 600).
intensitynumber—0–1 (offset ≤ 6 px; default 0.4).
ratenumber—Slice changes per second 1–3 (hard cap 3; default 3).
reducedMotionReducedMotion——
seednumber1Integer seed of the slice pattern (default 1).
triggerGlitchTrigger——

D08 · Displacement hover

<DisplacementHover> distorts an image on hover and focus through a map (a URL, an image, a canvas or generated "noise"): strength, scale and edge. Remote maps need CORS headers.

Import
@neshel-ui/animations/gpu
API
DisplacementHover, createDisplacementHover
Stylesheet
@neshel-ui/animations/gpu.css
Reduced motion
static — the decoration or content stays still
Performance
Uses a WebGL2 context from a page budget and draws only when something changes; the original content is the fallback.
Preview: D08
Preview theme: D08

Loading the example…

d08.tsx
"use client";
import "@neshel-ui/animations/gpu.css";
import { DisplacementHover } from "@neshel-ui/animations/gpu";
import { picture } from "./picture";

export default function D08Example() {
  return (
    <DisplacementHover className="w-80 max-w-full rounded-xl">
      <img src={picture("Displace", 20, 330)} alt="Warm gradient" width={640} height={400} />
    </DisplacementHover>
  );
}
Options: DisplacementHoverOptions

DisplacementHoverOptions

DisplacementHoverOptions
PropTypeDefaultDescription
channels"rg" | "r" | "g"——
crossOrigin"anonymous" | "use-credentials"——
edge"clamp" | "mirror" | "fade"——
focusbooleantrueAlso on :focus-visible within the frame (default true).
imageHTMLImageElement | HTMLCanvasElement——
mapMapSource | "noise"—URL, <img>, <canvas>, ImageBitmap or "noise" (default).
maxDprnumber——
pointerTypesreadonly ("mouse" | "pen" | "touch")[]——
reducedMotionReducedMotion——
scalenumber1Map tiling 0.25–4 (default 1).
seednumber1Seed of the built-in noise map (default 1).
springSpringOptions——
strengthnumber—0–1 (≤ 0.08 UV; default 0.5).

D09 · Perspective grid

<PerspectiveGrid> draws a floor that recedes to a horizon and moves at speed for duration (5 s by default). It is one decorative layer behind your content, with play() and pause().

Import
@neshel-ui/animations/advanced
API
PerspectiveGrid, createPerspectiveGrid
Stylesheet
@neshel-ui/animations/advanced.css
Reduced motion
static — the decoration or content stays still
Performance
The package stylesheet renders it on layers owned by the package; your element gets no transition or animation.
Preview: D09
Preview theme: D09
Horizon
d09.tsx
"use client";
import "@neshel-ui/animations/advanced.css";
import { type GridControl, PerspectiveGrid } from "@neshel-ui/animations/advanced";
import { Button } from "@neshel-ui/components";
import { useRef } from "react";

export default function D09Example() {
  const grid = useRef<GridControl | null>(null);
  return (
    <div className="grid justify-items-start gap-3">
      <PerspectiveGrid
        controlRef={grid}
        color="#a855f7"
        className="h-56 w-full rounded-xl bg-[#0b1020] p-6 text-white"
      >
        Horizon
      </PerspectiveGrid>
      <Button variant="outline" onClick={() => grid.current?.play()}>
        Run again
      </Button>
    </div>
  );
}
Options: PerspectiveGridOptions

PerspectiveGridOptions

PerspectiveGridOptions
PropTypeDefaultDescription
anglenumber72Plane tilt, deg 45–85 (default 72).
cellnumber48Cell size px 8–256 (default 48).
colorstringcurrentColorLine colour (default currentColor).
driftnumber0Lateral cells per second −4–4 (default 0).
durationnumber5000Running time ms 0–600000 or Infinity (default 5000).
fadebooleantrueFade toward the horizon (default true).
horizonnumber0.45Horizon as a fraction of the height 0–0.9 (default 0.45).
linenumber2Line width px 1–6 (default 2).
opacitynumber0.8Opacity 0.05–1 (default 0.8).
reducedMotionReducedMotion——
speednumber1Cells per second toward the viewer 0–8 (default 1).
vanishingnumber0.5Horizontal vanishing point 0–1 (default 0.5).

D10 · Depth parallax

<DepthParallax> shifts an image by a grayscale depth map (white is near) as the pointer moves. The map is required, with the same aspect ratio within 2 %: depth is never estimated.

Import
@neshel-ui/animations/gpu
API
DepthParallax, createDepthParallax
Stylesheet
@neshel-ui/animations/gpu.css
Reduced motion
static — the decoration or content stays still
Performance
Uses a WebGL2 context from a page budget and draws only when something changes; the original content is the fallback.
Preview: D10
Preview theme: D10

Loading the example…

d10.tsx
"use client";
import "@neshel-ui/animations/gpu.css";
import { DepthParallax } from "@neshel-ui/animations/gpu";
import { useMemo } from "react";
import { depthMap, picture } from "./picture";

export default function D10Example() {
  const depth = useMemo(depthMap, []);
  return (
    <DepthParallax depth={depth} className="w-80 max-w-full rounded-xl">
      <img
        src={picture("Depth", 150, 200)}
        alt="Teal landscape with a raised disc"
        width={640}
        height={400}
      />
    </DepthParallax>
  );
}
Options: DepthParallaxOptions

DepthParallaxOptions

DepthParallaxOptions
PropTypeDefaultDescription
crossOrigin"anonymous" | "use-credentials"——
depth(required)MapSource—Grayscale depth map (required): URL, <img>, <canvas> or ImageBitmap.
focusnumber0.5Depth that stays still 0–1 (default 0.5).
fromParallaxPose—Poses of seek(0) and seek(1) (default x −1 → 1).
imageHTMLImageElement | HTMLCanvasElement——
intensitynumber—0–1 (≤ 0.06 UV; default 0.5).
invertboolean—Black = near (default false: white = near).
maxDprnumber——
pointerbooleantrueFollow the pointer (default true).
pointerTypesreadonly ("mouse" | "pen" | "touch")[]——
reducedMotionReducedMotion——
springSpringOptions——
stepsnumber8Refinement steps 1–16 (default 8).
toParallaxPose——

D11 · Tilt shift

<TiltShift> blurs the edges around a focal band: orientation, focus, size and blur (6 px, up to 12). Without backdrop-filter it draws a tint instead. Keep text inside the focal band.

Import
@neshel-ui/animations/advanced
API
TiltShift, createTiltShift
Stylesheet
@neshel-ui/animations/advanced.css
Reduced motion
static — the decoration or content stays still
Performance
Uses a filter over the whole area, which is expensive on large surfaces; use it on small or static regions.
Preview: D11
Preview theme: D11

Loading the example…

d11.tsx
"use client";
import "@neshel-ui/animations/advanced.css";
import { TiltShift } from "@neshel-ui/animations/advanced";
import { useState } from "react";

export default function D11Example() {
  const [focus, setFocus] = useState(50);
  return (
    <div className="grid max-w-md gap-3">
      <TiltShift focus={focus / 100} className="rounded-xl">
        <div className="grid grid-cols-4 gap-2 bg-neshel-muted p-2">
          {Array.from({ length: 16 }, (_, index) => (
            <span
              key={index}
              className="rounded bg-neshel-primary p-3 text-neshel-primary-foreground"
            >
              {index + 1}
            </span>
          ))}
        </div>
      </TiltShift>
      <label className="grid gap-1">
        Focus
        <input
          type="range"
          min={10}
          max={90}
          value={focus}
          onChange={(event) => setFocus(Number(event.currentTarget.value))}
        />
      </label>
    </div>
  );
}
Options: TiltShiftOptions

TiltShiftOptions

TiltShiftOptions
PropTypeDefaultDescription
bandsnumber2Bands per side 1–2 (default 2).
blurnumber6Maximum blur px 0–12 (default 6).
fallback"tint" | "none"—Without backdrop-filter: a tint gradient (default) or nothing.
focusnumber0.5Focal centre 0–1 (default 0.5).
orientation"horizontal" | "vertical" | "radial"——
progressProgressSource—0–1 source moving the focal centre.
reducedMotionReducedMotion——
sizenumber0.35Focal band 0.1–0.9 (default 0.35).
springSpringOptions——
tintstring——
Edit on GitHub

On this page