Advanced 3D & Distortion
The 11 effects D01–D11: purpose, API, options, examples, reduced motion and cost.
Experimental and not on npm
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.
Loading the example…
"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
| Prop | Type | Default | Description |
|---|---|---|---|
| axis | "y" | "x" | — | — |
| back | HTMLElement | — | — |
| direction | 1 | -1 | — | — |
| flipped | boolean | false | Start on the back (default false). |
| front | HTMLElement | — | Faces (default: the inner element's first two element children). |
| inner | HTMLElement | — | 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. |
| perspective | number | 1200 | px 200–4000 (default 1200). |
| reducedEffect | "fade" | "instant" | — | Under reduced motion: cross-fade (default) or jump. |
| reducedMotion | ReducedMotion | — | — |
| spring | SpringOptions | — | — |
| toggleSelector | string | 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.
Loading the example…
"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
| Prop | Type | Default | Description |
|---|---|---|---|
| axis | Axis3D | — | — |
| duration | number | 700 | ms 0–10000 (default 700). |
| easing | Easing | EasingPreset | — | — |
| index | number | 0 | Initial panel (default 0). |
| loop | boolean | true | Wrap around at the ends (default true). |
| onChange | (index: number) => void | — | — |
| perspective | number | 1600 | px 200–6000 (default 1600). |
| reducedMotion | ReducedMotion | — | — |
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.
Loading the example…
"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
| Prop | Type | Default | Description |
|---|---|---|---|
| announce | (index: number, count: number) => string | "Slide n of N" | Text of the live announcement (default "Slide n of N"). |
| drag | boolean | — | — |
| gap | number | — | px 0–400 between items (auto radius; default 24). |
| index | number | — | — |
| keyboard | boolean | — | — |
| label | string | — | Accessible name of the carousel (required unless the root is labelled). |
| onChange | (index: number) => void | — | — |
| perspective | number | 1400 | px 200–6000 (default 1400). |
| radius | "auto" | number | — | "auto" (from the item width) or px 50–4000. |
| reducedMotion | ReducedMotion | — | — |
| spring | SpringOptions | — | — |
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.
Loading the example…
"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
| Prop | Type | Default | Description |
|---|---|---|---|
| back | string | #f1f5f9 | CSS colour of the page's reverse (default #f1f5f9). |
| corner | Corner | — | — |
| driver | "auto" | "gpu" | "css" | — | "auto" (GPU, CSS fallback), "gpu" (static without WebGL2) or "css" (rigid turn; live HTML). |
| duration | number | — | ms (0–10000; default per effect). |
| easing | Easing | EasingPreset | — | — |
| front | HTMLElement | — | The page that turns (GPU: <img>/<canvas>; CSS: any element; default: the frame's first child). |
| maxDpr | number | — | — |
| 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 | — | — |
| progress | ProgressSource | — | Drive from a 0–1 source instead of the own clock. |
| radius | number | 0.1 | Curl radius as a fraction of the diagonal 0.02–0.4 (default 0.1). |
| reducedMotion | ReducedMotion | — | — |
| shading | number | 0.6 | 0–1 (default 0.6). |
| trigger | "manual" | "mount" | — | "manual" (default) or "mount". |
| under | HTMLElement | — | 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.
The corner under the pointer folds away.
Read more"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
| Prop | Type | Default | Description |
|---|---|---|---|
| angle | number | 60 | Maximum fold angle, deg 10–85 (default 60). |
| corners | readonly 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"). |
| focusCorner | Corner | false | "top-right" | Corner folded at 35 % while focus inside is :focus-visible; false disables (default "top-right"). |
| perspective | number | 900 | px 300–3000 perspective of the flap (default 900). |
| pointerTypes | readonly ("mouse" | "pen" | "touch")[] | — | — |
| reducedMotion | ReducedMotion | — | — |
| reverse | boolean | false | Lift the corner toward the viewer instead of receding (default false). |
| shade | number | 0.3 | Flap darkening 0–0.6 (default 0.3). |
| size | number | 0.35 | Fold leg as a fraction of the shorter side 0.1–0.6 (default 0.35). |
| spring | SpringOptions | — | — |
| surface | HTMLElement | — | The live content element that is clipped (default: the root's first element child). |
| threshold | number | 0.3 | Neutral 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.
Loading the example…
"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
| Prop | Type | Default | Description |
|---|---|---|---|
| amplitude | number | — | 0–1 (≤ 0.03 UV; default 0.5). |
| damping | number | 2.5 | 0.5–6 per second (default 2.5). |
| duration | number | 2400 | ms of the seek/drive timeline 200–10000 (default 2400). |
| frequency | number | 1 | 0.5–4 (default 1). |
| image | HTMLImageElement | HTMLCanvasElement | — | The raster source (default: the frame's first img/canvas). |
| maxDpr | number | — | — |
| maxImpacts | number | 4 | 1–8 simultaneous impacts (default 4). |
| reducedMotion | ReducedMotion | — | — |
| seed | number | 1 | Integer seed of the seek/drive pattern (default 1). |
| speed | number | 0.45 | 0.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.
NESHEL SIGNAL
"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
| Prop | Type | Default | Description |
|---|---|---|---|
| colors | readonly [string, string] | — | Two CSS colours of the channel layers. |
| duration | number | 600 | Burst length ms 100–2000 (default 600). |
| intensity | number | — | 0–1 (offset ≤ 6 px; default 0.4). |
| rate | number | — | Slice changes per second 1–3 (hard cap 3; default 3). |
| reducedMotion | ReducedMotion | — | — |
| seed | number | 1 | Integer seed of the slice pattern (default 1). |
| trigger | GlitchTrigger | — | — |
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.
Loading the example…
"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
| Prop | Type | Default | Description |
|---|---|---|---|
| channels | "rg" | "r" | "g" | — | — |
| crossOrigin | "anonymous" | "use-credentials" | — | — |
| edge | "clamp" | "mirror" | "fade" | — | — |
| focus | boolean | true | Also on :focus-visible within the frame (default true). |
| image | HTMLImageElement | HTMLCanvasElement | — | — |
| map | MapSource | "noise" | — | URL, <img>, <canvas>, ImageBitmap or "noise" (default). |
| maxDpr | number | — | — |
| pointerTypes | readonly ("mouse" | "pen" | "touch")[] | — | — |
| reducedMotion | ReducedMotion | — | — |
| scale | number | 1 | Map tiling 0.25–4 (default 1). |
| seed | number | 1 | Seed of the built-in noise map (default 1). |
| spring | SpringOptions | — | — |
| strength | number | — | 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.
"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
| Prop | Type | Default | Description |
|---|---|---|---|
| angle | number | 72 | Plane tilt, deg 45–85 (default 72). |
| cell | number | 48 | Cell size px 8–256 (default 48). |
| color | string | currentColor | Line colour (default currentColor). |
| drift | number | 0 | Lateral cells per second −4–4 (default 0). |
| duration | number | 5000 | Running time ms 0–600000 or Infinity (default 5000). |
| fade | boolean | true | Fade toward the horizon (default true). |
| horizon | number | 0.45 | Horizon as a fraction of the height 0–0.9 (default 0.45). |
| line | number | 2 | Line width px 1–6 (default 2). |
| opacity | number | 0.8 | Opacity 0.05–1 (default 0.8). |
| reducedMotion | ReducedMotion | — | — |
| speed | number | 1 | Cells per second toward the viewer 0–8 (default 1). |
| vanishing | number | 0.5 | Horizontal 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.
Loading the example…
"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
| Prop | Type | Default | Description |
|---|---|---|---|
| crossOrigin | "anonymous" | "use-credentials" | — | — |
| depth(required) | MapSource | — | Grayscale depth map (required): URL, <img>, <canvas> or ImageBitmap. |
| focus | number | 0.5 | Depth that stays still 0–1 (default 0.5). |
| from | ParallaxPose | — | Poses of seek(0) and seek(1) (default x −1 → 1). |
| image | HTMLImageElement | HTMLCanvasElement | — | — |
| intensity | number | — | 0–1 (≤ 0.06 UV; default 0.5). |
| invert | boolean | — | Black = near (default false: white = near). |
| maxDpr | number | — | — |
| pointer | boolean | true | Follow the pointer (default true). |
| pointerTypes | readonly ("mouse" | "pen" | "touch")[] | — | — |
| reducedMotion | ReducedMotion | — | — |
| spring | SpringOptions | — | — |
| steps | number | 8 | Refinement steps 1–16 (default 8). |
| to | ParallaxPose | — | — |
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.
Loading the example…
"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
| Prop | Type | Default | Description |
|---|---|---|---|
| bands | number | 2 | Bands per side 1–2 (default 2). |
| blur | number | 6 | Maximum blur px 0–12 (default 6). |
| fallback | "tint" | "none" | — | Without backdrop-filter: a tint gradient (default) or nothing. |
| focus | number | 0.5 | Focal centre 0–1 (default 0.5). |
| orientation | "horizontal" | "vertical" | "radial" | — | — |
| progress | ProgressSource | — | 0–1 source moving the focal centre. |
| reducedMotion | ReducedMotion | — | — |
| size | number | 0.35 | Focal band 0.1–0.9 (default 0.35). |
| spring | SpringOptions | — | — |
| tint | string | — | — |