---
title: Liquid image reveal
description: An organic reveal with SVG filters.
category: Cursor
tier: free
url: https://ui.dimaac.com/components/liquid-image-reveal
registry: https://ui.dimaac.com/r/liquid-image-reveal.json
---

# Liquid image reveal

A photo revealed through a circle that grows from a point, with an edge that wobbles like a puddle because an SVG noise filter pushes it around. It plays when the image scrolls into view, and clicking (or pressing Enter on) it closes the puddle and opens it again from that exact spot. It fills any box, resizes cleanly, ids are unique so several can share a page, and with reduced motion the image is simply there. Ported from the first DiMaac UI and rebuilt with useGSAP: a responsive box instead of fixed pixels, light octaves by default so phones stay smooth, a real accessible name, and a replay.

## Install

With the shadcn CLI:

```bash
npx shadcn@latest add https://ui.dimaac.com/r/liquid-image-reveal.json
pnpm dlx shadcn@latest add https://ui.dimaac.com/r/liquid-image-reveal.json
bunx --bun shadcn@latest add https://ui.dimaac.com/r/liquid-image-reveal.json
```

With the `@dimaac` namespace in components.json: `npx shadcn@latest add @dimaac/liquid-image-reveal`

Dependencies:

```bash
pnpm add gsap @gsap/react
npm install gsap @gsap/react
```

By hand:

1. Install the packages it uses: gsap, @gsap/react.
2. Copy the component file below into components/dimaac/liquid-image-reveal.tsx.
3. It's styled with Tailwind v4 classes. If that folder sits outside the places Tailwind scans, add it with @source in your CSS.
4. Import it with import { LiquidImageReveal } from "@/components/dimaac/liquid-image-reveal". Give its parent a size: it fills it.

## Usage

```tsx
import { LiquidImageReveal } from "@/components/dimaac/liquid-image-reveal";

<LiquidImageReveal src={src} alt={alt} />
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `src` (required) | `string` | - | The image address. |
| `alt` (required) | `string` | - | What the image shows. It becomes the accessible name of the whole piece. |
| `width` | `number \| string` | `"100%"` | Width of the box: a number in pixels or any CSS length. It fills its parent by default. |
| `height` | `number \| string` | `"100%"` | Height of the box: a number in pixels or any CSS length. It fills its parent by default. |
| `duration` | `number` | `2.2` | How long the reveal takes, in seconds. |
| `delay` | `number` | `0` | Seconds to wait before the reveal starts. |
| `ease` | `string` | `"power2.out"` | The GSAP ease of the reveal, e.g. "power2.out" or "expo.out". |
| `trigger` | `"visible" \| "mount"` | `"visible"` | When the first reveal plays: "visible" waits until the image is scrolled into view, "mount" plays straight away. |
| `replayOnClick` | `boolean` | `true` | Clicking (or pressing Enter on) the image closes the puddle and opens it again from that spot. |
| `centerX` | `number` | `0.5` | Where the puddle starts, across the box: 0 is the left edge, 0.5 the middle, 1 the right edge. |
| `centerY` | `number` | `0.5` | Where the puddle starts, down the box: 0 is the top edge, 0.5 the middle, 1 the bottom edge. |
| `maxRadius` | `number` | - | How big the circle gets, in pixels. Leave empty to grow just enough to cover the whole image. |
| `turbulenceFrequency` | `number` | `0.02` | How fine the wobble is. Small numbers give big slow waves, large numbers give small ripples. |
| `turbulenceOctaves` | `number` | `3` | Layers of detail in the wobble. More looks richer but costs more on phones. 2 to 4 is plenty. |
| `displacementScale` | `number` | `80` | How far the noise pushes the edge, in pixels. 0 is a clean circle. |
| `onComplete` | `() => void` | - | Called every time a reveal finishes. |
| `className` | `string` | `""` | Extra classes for the outer box, e.g. a radius. |

## Credits

- Photo: orange visor: West Kast, Lummi (https://www.lummi.ai/photo/fashion-portrait-with-orange-visor-damql), Lummi License
- Photo: lime blazer: Amino, Lummi (https://www.lummi.ai/photo/vivid-portrait-on-pink-oxbow), Lummi License
- Photo: neon profile: Shaun Duval, Lummi (https://www.lummi.ai/photo/portrait-with-neon-sunglasses-gindg), Lummi License

## Source

### liquid-image-reveal.tsx → `components/dimaac/liquid-image-reveal.tsx`

```tsx
"use client";

import { useCallback, useId, useRef, type CSSProperties } from "react";
import { gsap } from "gsap";
import { useGSAP } from "@gsap/react";

// An image that opens like a drop of liquid. A circle grows from a point and the image shows
// through it. The edge of the circle is pushed around by an SVG noise filter, so it wobbles like
// a puddle instead of a clean circle. Click it and the puddle closes, then opens again from
// wherever you clicked.

export type LiquidImageRevealProps = {
  /** The image address. */
  src: string;
  /** What the image shows. It becomes the accessible name of the whole piece. */
  alt: string;
  /** Width of the box: a number in pixels or any CSS length. It fills its parent by default. */
  width?: number | string;
  /** Height of the box: a number in pixels or any CSS length. It fills its parent by default. */
  height?: number | string;
  /** How long the reveal takes, in seconds. */
  duration?: number;
  /** Seconds to wait before the reveal starts. */
  delay?: number;
  /** The GSAP ease of the reveal, e.g. "power2.out" or "expo.out". */
  ease?: string;
  /** When the first reveal plays: "visible" waits until the image is scrolled into view, "mount" plays straight away. */
  trigger?: "visible" | "mount";
  /** Clicking (or pressing Enter on) the image closes the puddle and opens it again from that spot. */
  replayOnClick?: boolean;
  /** Where the puddle starts, across the box: 0 is the left edge, 0.5 the middle, 1 the right edge. */
  centerX?: number;
  /** Where the puddle starts, down the box: 0 is the top edge, 0.5 the middle, 1 the bottom edge. */
  centerY?: number;
  /** How big the circle gets, in pixels. Leave empty to grow just enough to cover the whole image. */
  maxRadius?: number;
  /** How fine the wobble is. Small numbers give big slow waves, large numbers give small ripples. */
  turbulenceFrequency?: number;
  /** Layers of detail in the wobble. More looks richer but costs more on phones. 2 to 4 is plenty. */
  turbulenceOctaves?: number;
  /** How far the noise pushes the edge, in pixels. 0 is a clean circle. */
  displacementScale?: number;
  /** Called every time a reveal finishes. */
  onComplete?: () => void;
  /** Extra classes for the outer box, e.g. a radius. */
  className?: string;
};

const toCss = (value: number | string) => (typeof value === "number" ? `${value}px` : value);

export function LiquidImageReveal({
  src,
  alt,
  width = "100%",
  height = "100%",
  duration = 2.2,
  delay = 0,
  ease = "power2.out",
  trigger = "visible",
  replayOnClick = true,
  centerX = 0.5,
  centerY = 0.5,
  maxRadius,
  turbulenceFrequency = 0.02,
  turbulenceOctaves = 3,
  displacementScale = 80,
  onComplete,
  className = "",
}: LiquidImageRevealProps) {
  const boxRef = useRef<HTMLElement | null>(null);
  const setBox = useCallback((node: HTMLElement | null) => {
    boxRef.current = node;
  }, []);
  const maskRef = useRef<SVGMaskElement>(null);
  const filterRef = useRef<SVGFilterElement>(null);
  const circleRef = useRef<SVGCircleElement>(null);

  // SVG ids can't hold the colons React puts in useId, and two copies on a page need different ids
  const uid = useId().replace(/[^a-zA-Z0-9_-]/g, "");
  const maskId = `liquid-mask-${uid}`;
  const filterId = `liquid-filter-${uid}`;

  // Values the animation reads while it runs. Only the callback is live; the look props restart the reveal
  // (see the dependencies below), so a new wobble is always shown by playing it, never hidden behind a finished mask.
  const live = useRef({ displacementScale, maxRadius, onComplete });
  live.current = { displacementScale, maxRadius, onComplete };

  useGSAP(
    (_context, contextSafe) => {
      const box = boxRef.current;
      const mask = maskRef.current;
      const filter = filterRef.current;
      const circle = circleRef.current;
      if (!box || !mask || !filter || !circle || !contextSafe) return;

      // progress: 0 is closed, 1 is fully open. The radius is worked out from it on every draw,
      // so a resize in the middle of a reveal still ends up covering the whole image.
      const state = { progress: 0 };
      const origin = { x: centerX, y: centerY };

      const draw = () => {
        const w = box.clientWidth;
        const h = box.clientHeight;
        const { displacementScale: scale, maxRadius: fixedRadius } = live.current;
        // The noise pulls pixels in from outside the box, so the filter and mask regions are a
        // little bigger than the box. Otherwise the edges would get transparent holes.
        const pad = Math.ceil(scale) + 2;
        for (const el of [mask, filter]) {
          el.setAttribute("x", String(-pad));
          el.setAttribute("y", String(-pad));
          el.setAttribute("width", String(w + pad * 2));
          el.setAttribute("height", String(h + pad * 2));
        }
        const cx = origin.x * w;
        const cy = origin.y * h;
        // The farthest corner, plus the most the noise can pull the edge back
        const farthest = Math.hypot(Math.max(cx, w - cx), Math.max(cy, h - cy)) + scale * 0.6;
        circle.setAttribute("cx", String(cx));
        circle.setAttribute("cy", String(cy));
        circle.setAttribute("r", String(state.progress * (fixedRadius ?? farthest)));
      };

      draw();
      const resizeObserver = new ResizeObserver(draw);
      resizeObserver.observe(box);

      // Reduced motion: no growing circle. The image is simply there.
      const reduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
      if (reduced) {
        state.progress = 1;
        draw();
        return () => resizeObserver.disconnect();
      }

      const open = (wait: number) => {
        gsap.to(state, {
          progress: 1,
          duration,
          delay: wait,
          ease,
          onUpdate: draw,
          onComplete: () => live.current.onComplete?.(),
        });
      };

      // Close quickly toward the old spot, then open again from the new one
      const reopenFrom = (x: number, y: number) => {
        gsap.killTweensOf(state);
        gsap.to(state, {
          progress: 0,
          duration: Math.min(0.6, duration * 0.3),
          ease: "power2.in",
          onUpdate: draw,
          onComplete: () => {
            origin.x = x;
            origin.y = y;
            open(0.05);
          },
        });
      };

      const onClick = contextSafe((event: MouseEvent) => {
        if (!replayOnClick) return;
        const rect = box.getBoundingClientRect();
        // A keyboard press has no position (detail is 0), so it reopens from the usual spot
        const fromKeyboard = event.detail === 0;
        const x = fromKeyboard ? centerX : (event.clientX - rect.left) / rect.width;
        const y = fromKeyboard ? centerY : (event.clientY - rect.top) / rect.height;
        reopenFrom(Math.min(1, Math.max(0, x)), Math.min(1, Math.max(0, y)));
      });
      box.addEventListener("click", onClick);

      // Wait until the image is on screen, so the reveal isn't spent while nobody is looking
      let visibility: IntersectionObserver | null = null;
      if (trigger === "visible" && typeof IntersectionObserver !== "undefined") {
        visibility = new IntersectionObserver(
          ([entry]) => {
            if (!entry?.isIntersecting) return;
            visibility?.disconnect();
            open(delay);
          },
          { threshold: 0.35 },
        );
        visibility.observe(box);
      } else {
        open(delay);
      }

      return () => {
        visibility?.disconnect();
        resizeObserver.disconnect();
        box.removeEventListener("click", onClick);
        gsap.killTweensOf(state);
      };
    },
    { scope: boxRef, dependencies: [duration, delay, ease, trigger, replayOnClick, centerX, centerY, displacementScale, turbulenceFrequency, turbulenceOctaves, maxRadius], revertOnUpdate: true },
  );

  const boxStyle: CSSProperties = { width: toCss(width), height: toCss(height) };

  const picture = (
    <svg className="absolute inset-0 block h-full w-full" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false">
      <defs>
        {/* The liquid edge: noise that pushes the circle's pixels around. sRGB keeps the push
            even in every direction. */}
        <filter id={filterId} filterUnits="userSpaceOnUse" colorInterpolationFilters="sRGB" ref={filterRef}>
          <feTurbulence type="fractalNoise" baseFrequency={turbulenceFrequency} numOctaves={turbulenceOctaves} result="noise" />
          <feDisplacementMap in="SourceGraphic" in2="noise" scale={displacementScale} xChannelSelector="R" yChannelSelector="G" />
        </filter>
        {/* White shows the image, black hides it. The growing circle is the white part. */}
        <mask id={maskId} maskUnits="userSpaceOnUse" ref={maskRef}>
          <circle ref={circleRef} r="0" fill="white" filter={`url(#${filterId})`} />
        </mask>
      </defs>
      <image href={src} width="100%" height="100%" preserveAspectRatio="xMidYMid slice" mask={`url(#${maskId})`} />
    </svg>
  );

  const shared = `relative block overflow-hidden ${className}`;

  if (replayOnClick) {
    return (
      <button
        type="button"
        ref={setBox}
        aria-label={`${alt}. Press to replay the reveal.`}
        className={`${shared} cursor-pointer border-0 bg-transparent p-0 text-left focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current`}
        style={boxStyle}
      >
        {picture}
      </button>
    );
  }

  return (
    <div ref={setBox} role="img" aria-label={alt} className={shared} style={boxStyle}>
      {picture}
    </div>
  );
}
```

### demo.tsx (the demo on the page, not installed)

```tsx
"use client";

import { LiquidImageReveal, type LiquidImageRevealProps } from "@/components/dimaac/liquid-image-reveal";

// Three portraits, each opening from a different spot and a beat after the one before it.
// Click any of them to close the puddle and open it again from where you clicked.
// Photos from Lummi (Lummi License: free for personal and commercial use).

const frames = [
  { file: "fashion/orange-visor-4x5.jpg", alt: "A woman in an orange visor and navy dress against a teal background", title: "Visor", note: "No. 01", x: 0.5, y: 0.5 },
  { file: "portraits/lime-blazer-4x5.jpg", alt: "A person with curly red hair in a lime green blazer against a pink background", title: "Blazer", note: "No. 02", x: 0.2, y: 0.8 },
  { file: "portraits/neon-profile-4x5.jpg", alt: "A woman in neon pink sunglasses in profile against a blue background", title: "Neon", note: "No. 03", x: 0.8, y: 0.25 },
];

export default function Demo(props: Partial<LiquidImageRevealProps>) {
  const { delay = 0, centerX = 0.5, centerY = 0.5, ...rest } = props;
  // Each frame has its own start spot. Moving the playground's Start sliders sends all three to the same one.
  const customStart = centerX !== 0.5 || centerY !== 0.5;
  const startX = (frame: (typeof frames)[number]) => (customStart ? centerX : frame.x);
  const startY = (frame: (typeof frames)[number]) => (customStart ? centerY : frame.y);

  return (
    <div className="relative flex h-full w-full flex-col overflow-hidden bg-[#f3f0eb] px-5 py-5 text-[#1c1917] md:px-12 md:py-9 dark:bg-[#0f0d0c] dark:text-[#ece4dc]">
      <div className="grid min-h-0 flex-1 grid-cols-2 grid-rows-[1.2fr_1fr] gap-x-3 gap-y-3 md:grid-cols-3 md:grid-rows-1 md:gap-6">
        {frames.map((frame, index) => (
          <figure key={frame.file} className={`flex min-h-0 flex-col gap-2.5 md:gap-3 ${index === 0 ? "col-span-2 md:col-span-1" : ""}`}>
            <div className="min-h-0 flex-1 rounded-[3px] bg-black/[0.06] dark:bg-white/[0.06]">
              <LiquidImageReveal
                {...rest}
                src={media(frame.file)}
                alt={frame.alt}
                delay={delay + index * 0.35}
                centerX={startX(frame)}
                centerY={startY(frame)}
                className="rounded-[3px]"
              />
            </div>
            <figcaption className="flex shrink-0 justify-between font-mono text-[10px] tracking-wide uppercase opacity-70 md:text-[11px]">
              <span>{frame.title}</span>
              <span>{frame.note}</span>
            </figcaption>
          </figure>
        ))}
      </div>

      <p className="mt-4 shrink-0 text-center font-mono text-[11px] tracking-wide uppercase opacity-60 md:mt-6">Click a frame to pour it again</p>
    </div>
  );
}
```

## Agent prompt

```text
Add the Liquid image reveal component (<LiquidImageReveal />) from DiMaac UI to this project.

Docs: https://ui.dimaac.com/components/liquid-image-reveal
Source and dependencies (shadcn registry JSON): https://ui.dimaac.com/r/liquid-image-reveal.json

Install it with:
npx shadcn@latest add https://ui.dimaac.com/r/liquid-image-reveal.json

Then use it like this:
import { LiquidImageReveal } from "@/components/dimaac/liquid-image-reveal";
<LiquidImageReveal src={src} alt={alt} />

If the shadcn CLI isn't set up here, fetch the registry JSON above, write files[0].content to components/dimaac/liquid-image-reveal.tsx and install gsap, @gsap/react.
It uses Tailwind v4 classes, so make sure Tailwind scans that folder. Give its parent a size: it fills it. Keep light and dark mode working and keep its prefers-reduced-motion fallback.
Full index for agents: https://ui.dimaac.com/llms.txt
```
