Skip to content

Morph frame

Pro effect

Most Shavin FX effects are free. This one is part of Shavin FX Pro, in early access. Join the Pro waitlist and we will email you once when access opens. You can preview it here in the meantime.

Join the FX Pro waitlist

A picture, video or any content shown in an organic window that changes shape: arch, pill, tulip, bell, circle, squircle, ticket, scoop or your own SVG path. The edge acts like a thin lens, bending the picture inward with a chromatic fringe under a rim light. Use it for an editorial hero, portfolio cards that react on hover, a scroll story, or a title that changes colour where it crosses the picture.

Playground

A Marshall speaker resting on green and gold silk
Still life

Shape

Media

Title

Title colour

Install

npm install @shavin/fx
import { MorphFrame, MorphFrameStack, MorphFrameLabel } from "@shavin/fx";

Works with

React

Client component; Next.js and any React 18+ app

Remotion

Frame-exact through FxTimeProvider, time or progress; the lens renders in Remotion's Chromium

Editorial hero

The picture's window drifts between a few related shapes while the copy stays still. Slow holds and a longer morph keep it calm enough to sit beside a headline.

Field journal

The hour before dark

Twelve evenings in the hills, photographed in the last forty minutes of light.

Golden hills around a still pond at dusk
Component Source
import { MorphFrame } from "@shavin/fx";

<div className="grid items-center gap-10 md:grid-cols-[1fr_1.1fr]">
  <div className="flex flex-col gap-4">
    <Text size="xs" className="uppercase tracking-widest text-fg-subtle">Field journal</Text>
    <Heading size="3xl">The hour before dark</Heading>
    <Text className="text-fg-subtle">Twelve evenings in the hills, photographed in the last forty minutes of light.</Text>
  </div>
  <MorphFrame
    src={imageUrl("golden-hills-dusk", 1200)}
    alt="Golden hills around a still pond at dusk"
    shapes={["arch", "squircle", "tulip"]}
    interval={2600}
    duration={1400}
    className="aspect-[4/5] w-full max-w-sm"
  />
</div>

Title split by the edge

The title is real text in the page colour. Where it crosses the picture it switches to inverseColor, split at the moving edge. titleFringe adds a faint RGB offset that flares while the shape morphs.

A Marshall speaker resting on green and gold silk
ListenIn green and gold
Component Source
<MorphFrame
  src="/assets/hq_marshall.jpg"
  alt="A Marshall speaker resting on green and gold silk"
  shapes={["rect", "squircle", "arch"]}
  interval={2400}
  title="Listen"
  subtitle="In green and gold"
  titleFringe={1.2}
  titleSize="clamp(2rem, 26cqw, 6rem)"
  className="aspect-[3/4] w-72"
/>

Portfolio cards on hover

trigger="hover" morphs from the first shape to the second while the pointer is over the frame, and back when it leaves. Starting from a rectangle keeps the grid tidy at rest.

A Marshall speaker resting on green and gold silk

Still life

Product photography on fabric

A person holding a camera by a window

Portraits

Natural window light

A bright living room with a cream sofa in afternoon sun

Interiors

Rooms in afternoon sun

Component Source
{projects.map((p) => (
  <div key={p.name} className="flex flex-col gap-3">
    <MorphFrame src={p.src} alt={p.alt} shapes={["rect", p.shape]} trigger="hover" duration={700} refraction={0.35} className="aspect-[4/5] w-full" />
    <div className="flex flex-col gap-1">
      <Text size="sm" className="font-medium text-fg">{p.name}</Text>
      <Text size="sm" className="text-fg-subtle">{p.note}</Text>
    </div>
  </div>
))}

Shape picker

Every preset, as buttons. trigger="manual" morphs the big frame to the shape at index, so any control (tabs, a slider, a step in a form) can choose the window.

Portrait of a woman in natural light
Component Source
import { MorphFrame, MORPH_SHAPES } from "@shavin/fx";

const [index, setIndex] = useState(1);

<MorphFrame src={src} alt={alt} shapes={MORPH_SHAPES} trigger="manual" index={index} duration={900} className="aspect-[3/4] w-60" />
<div role="group" aria-label="Window shape">
  {MORPH_SHAPES.map((s, i) => (
    <button key={s} type="button" aria-pressed={i === index} onClick={() => setIndex(i)}>
      <MorphFrame src={src} alt="" shape={s} refraction={0} className="aspect-[3/4] w-10" />
      {s}
    </button>
  ))}
</div>

Scroll story

MorphFrameStack lays frames down a column under hairline labels. Scroll the box: each window morphs as it rises through the view, the picture drifts a little, and a title can sit on any frame.

Chapter 01
A Marshall speaker resting on green and gold silk
Chapter 02
Portrait of a woman with dark hair
PeoplePortraits in window light
Chapter 03
Chapter 04
Golden hills around a still pond at dusk
Component Source
import { MorphFrameStack } from "@shavin/fx";

<MorphFrameStack
  items={[
    { src: "/assets/hq_marshall.jpg", alt: "A Marshall speaker resting on green and gold silk", label: "Chapter 01", shapes: ["pill", "tulip"] },
    { src: imageUrl("portrait-lucia", 900), alt: "Portrait of a woman with dark hair", label: "Chapter 02", shapes: ["tulip", "bell"], title: "People", subtitle: "Portraits in window light" },
    { src: "/assets/dither-sample.mp4", alt: "A dithered video loop", label: "Chapter 03", shapes: ["bell", "arch"] },
  ]}
  frameProps={{ titleFringe: 2, parallax: 0.12, dispersion: 0.6 }}
/>

Scroll-driven

progress runs through the shapes, first (0) to last (1). Here the box's scroll position drives it, with a little parallax.

Soft morning light over a coastline wrapped in low clouds
Component Source
// e.g. from a scroll handler: scrollTop / (scrollHeight - clientHeight)
<MorphFrame src={imageUrl("coastal-sea-of-clouds", 900)} alt="Soft morning light over a coastline wrapped in low clouds" shapes={["circle", "arch", "tulip", "rect"]} progress={progress} parallax={0.15} />

Video in a frame

An .mp4, .webm or .mov src plays muted and looped inside the window. Here it morphs from a circle to a ticket on hover.

Component Source
<MorphFrame src="/assets/dither-sample.mp4" alt="A dithered video loop" shapes={["circle", "ticket"]} trigger="hover" dispersion={0.8} />

Custom path

Any SVG path, drawn in a 100 by 100 viewBox (or pass your own viewBox), is resampled and morphs with the presets.

A potted plant casting shadows on a violet wall
Component Source
const blob = { path: "M50 4 C70 0 96 14 94 40 C92 60 100 78 82 92 C64 104 36 98 20 88 C4 78 0 58 6 40 C12 20 30 8 50 4 Z" };

<MorphFrame src={imageUrl("plant-on-violet", 900)} alt="A potted plant casting shadows on a violet wall" shapes={[blob, "squircle"]} wobble={0.8} />

Driven by Remotion

Under FxTimeProvider each frame is computed from time, and images and video hold the render until they are ready.

A Marshall speaker resting on green and gold silk
Component Source
// Every frame is a pure function of time; images and video hold the render until ready.
const frame = useCurrentFrame();
const { fps, durationInFrames } = useVideoConfig();

<FxTimeProvider time={frame / fps} hold={(label) => { const h = delayRender(label); return () => continueRender(h); }}>
  {/* A morph cycle, frame-exact */}
  <MorphFrame src={staticFile("still-life.jpg")} alt="" shapes={["arch", "pill", "tulip"]} />
  {/* Or a whole scroll story that scrolls itself */}
  <MorphFrameStack items={items} progress={frame / (durationInFrames - 1)} />
</FxTimeProvider>

Browser support

The edge bend is an SVG filter on the window itself (not a backdrop filter), built from the clipped picture's own outline, so it follows every morph. Chromium (Chrome, Edge, Arc, Brave, and the headless Chrome Remotion renders with) and Firefox draw it. Safari keeps the shape, the morph, the specular rim, the inner shade and a drawn red and blue edge fringe, without the bend. The frame carries data-refraction="on" or "off" so you can check which one a reader got.

The filter re-runs whenever the picture changes, so a playing video under refraction costs more than a still; for long grids of video frames, or for small thumbnails, set refraction to 0. Under reduced motion the cycle holds the first shape, hover, manual and scroll swap shapes without animating, and the wobble, parallax and video autoplay stop.

Props

PropTypeDefaultDescription
srcstring—Image or video URL. .mp4, .webm and .mov play muted and looped.
altstring""Alt text (the video's accessible name). Empty for a decorative picture.
media"image" | "video"—Force how src is shown when its extension does not say.
objectPositionstring"center"object-position of the picture inside the window.
childrenReactNode—Content for the window instead of (or over) src; clipped and bent with it.
shapeMorphShape"arch"rect, arch, pill, oval, circle, squircle, tulip, bell, ticket, scoop-left, scoop-right, or { path, viewBox } for any SVG path.
shapesMorphShape[]—Shapes to morph between; overrides shape. MORPH_SHAPES lists every preset.
trigger"interval" | "hover" | "scroll" | "manual""interval"What moves it through shapes: a timed loop, hover (first to second), the frame's scroll position, or index.
indexnumber0For manual: the shape to morph to.
progressnumber—Drive it yourself, 0 first shape to 1 last (scroll, Remotion). Overrides trigger.
intervalnumber1800For interval: ms each shape holds.
durationnumber1100Ms a morph takes.
refractionnumber0.5How far the picture bends inward at the edge, 0 to 1.
bezelnumber—Width in px of the bending band (default 7% of the short side, 8 to 36).
dispersionnumber0.4Chromatic fringe where the edge bends, 0 to 1.
rimnumber0.6Specular rim light and inner edge shade, 0 to 1.
lightAnglenumber-45Direction the rim light comes from, CSS degrees (0 top).
wobblenumber0.3Liquid wobble while a shape morphs, 0 to 1; still at rest.
parallaxnumber0With trigger="scroll" or progress: the picture drifts inside the window, 0 to 0.3.
radiusnumber—Corner radius in px for shapes with corners (default 7% of the short side).
scalenumber1The window's size within the element, 0.3 to 1.
titleReactNode—A big title over the window: color on the page, inverseColor on the picture, split at the edge.
subtitleReactNode—A smaller line under the title, with the same split.
colorFxColor"fg"Title colour over the page: a theme token (fg, brand, muted), any CSS colour or var(--token), or a { light, dark } pair.
inverseColorFxColor"white"Title colour over the picture.
titleFringenumber0RGB-split fringe on the title in px, 0 to 6; it flares mid-morph.
titleSizestring"clamp(2rem, 15cqw, 9rem)"Title font size, relative to the frame's width by default.
titleClassName / titleStylestring / CSSProperties—Typography for the title block.
timenumber—Controlled time in seconds (e.g. frame / fps in Remotion); also read from FxTimeProvider.

MorphFrameStack props

PropTypeDefaultDescription
items{ src, alt, shapes, label, title, subtitle, children }[]—The frames, top to bottom; each morphs between its shapes (a pair picked by position if omitted).
progressnumber—Scroll the stack yourself, 0 top to 1 bottom: it fills its box and every frame's morph follows, frame-exact. Without it, a plain column following the page's scroll.
color / inverseColorFxColor—color for labels and titles over the page, inverseColor for titles over the pictures.
framePropsPartial<MorphFrameProps>—Passed to every frame (refraction, dispersion, titleFringe, parallax and so on).
frameClassNamestring"aspect-[4/5] w-full"Classes for every frame.
itemClassNamestring"w-full max-w-sm"Classes for each label and frame pair; sets the column width.
gapnumber96Px between frames.
timenumber—Controlled time in seconds; also read from FxTimeProvider.

MorphFrameLabel props

PropTypeDefaultDescription
childrenReactNode—The caption, set small and uppercase between two hairlines (e.g. "Chapter 01").
colorFxColor"fg"Label colour; the hairlines use it at low opacity.
align"start" | "center" | "end""center"Where the caption sits between its hairlines.
Configure Theme
Theme
Brand Color
Custom
Gray Family
Appearance
Radius
Scaling
Panel Style
Heading Font
Body Font