How to Build a Gooey Cursor Reveal in React (Halftone Image to Color)

Published: December 4, 2026 · 8 min read

Magic Link Sign-in. Email form on the left, dotted hillside on the right.
Magic Link Sign-in. Email form on the left, dotted hillside on the right.

On many sites, hovering a black-and-white dot picture brings the color in.

Asking an AI to build that motion often fails. The result is rarely right.

This article shows how to build it in React: color that changes when the pointer hovers.

A hard circle or a needle-like tail is easy to end up with

This motion is the right side of Magic Link Sign-in. The left side is the sign-in form, and the right side is a hillside photo.

The right side has a black-and-white dot image and a color image of the same photo. Until you hover, you see the dots.

The same motion is easy to get wrong. A hard hole can open in the dots, or the tail can grow long and pointed, so a fast move sends a needle across the photo.

When it works, it is not a hard circle or a sharp needle. Color appears only inside one soft blob that follows the cursor.

Tip 1: Stack the dot image and the color image

Use two images. Draw the dots first, draw the color photo of the same picture on top, and put the mask on the color image only.

tsx
<svg className="absolute inset-0 h-full w-full">
  <image href={dotsSrc} width="100%" height="100%" preserveAspectRatio="xMidYMid slice" />
  <image
    href={colorSrc}
    width="100%"
    height="100%"
    preserveAspectRatio="xMidYMid slice"
    mask={`url(#${maskId})`}
  />
</svg>

The mask shows only the inside of the blob, so outside it the color stays hidden and the dot image underneath remains visible.

If the two crops drift apart, the color inside the blob and the dots around it no longer show the same place. Keep both images in the same frame, and use the same preserveAspectRatio. Magic Link Sign-in uses xMidYMid slice on both, so the hillside is cropped in the same place.

Tip 2: Build the mask from 12 circles and keep the neck thick

Build the mask from 12 circles joined together. One circle looks like a sticker, and a long thin stretch looks like a needle, so these 12 circles make a short body that bends with the pointer.

ts
const HEAD_RADIUS = 40;
const TAIL_RADIUS = 26;
const COUNT = 12;

function radiusAt(index: number) {
  const t = index / (COUNT - 1);
  return HEAD_RADIUS + (TAIL_RADIUS - HEAD_RADIUS) * t;
}

The radius starts at about 40px on the first circle and gets smaller toward the back, ending at about 26px. The last circle stays round. It does not become a point.

Fill the space between neighbors with a polygon bounded by the outer tangents of both circles, so the join does not pinch. The neck stays thick. A thin line between the centers pinches the join, and the shape looks like two separate circles.

Tip 3: Blur the mask so the circles become one blob

Up to this point the mask is circles plus the polygons between them. Without a blur, the seams between the circles and the polygons stay visible. Blur them together and the seams disappear into one blob.

xml
<filter id={filterId} x="-40%" y="-40%" width="180%" height="180%">
  <feGaussianBlur in="SourceGraphic" stdDeviation="4" />
</filter>

The blur strength, stdDeviation, is 4. At that strength the seams hide and the edge gets soft. The first circle barely grows.

After the blur, do not add a color matrix that boosts alpha. That cuts into the smaller tail circles, leaves streaks, or draws a colored band on the edge. Magic Link Sign-in uses only this blur. There is no extra outline around the blob.

Tip 4: Lag the head and cap the space between circles

The pointer position is where the first circle is heading. The head does not arrive there at once. It follows a little behind, and when the direction changes it can overshoot slightly and then come back.

Each circle behind follows the circle in front of it. Without a cap on the gap, a fast move stretches the tail until it looks like a comet.

ts
vel.x += (target.x - head.x) * 0.2;
vel.x *= 0.7;
head.x += vel.x;

// Move toward the circle in front, then stop the gap at the cap.
const next = Math.min(22, Math.max(minDist, dist));
point.x = prev.x + (dx / dist) * next;
point.y = prev.y + (dy / dist) * next;

The lag comes from a pull toward the target of 0.2, and from multiplying velocity by 0.7 on every frame.

The distance between neighboring centers never goes past 22px. A fast move does not make the tail longer than that cap. What speed changes is how far the head lags.

Besides the cap, there is a minimum gap while the pointer is moving. Without that minimum, the circles pile up mid-move and collapse into a plain circle. When the pointer stops, the circles behind catch up, so the stretched blob returns to a shape close to a circle.

Tip 5: Turn it off for touch and reduced motion, and fade when the pointer leaves

This follow runs only on a desktop with a fine pointer, like a mouse, and only when the viewport is at least 768px wide. On a phone the blob does not appear. The dot image stays as it is.

tsx
const fine = window.matchMedia(
  "(min-width: 768px) and (hover: hover) and (pointer: fine)",
).matches;

if (!fine || event.pointerType === "touch") return;

// Reduced motion: place the blob under the pointer, with no tail.
// Otherwise, fade the color out over 300ms after the pointer leaves.

style={{
  opacity: shown ? 0.82 : 0,
  transition: over || reduced ? "none" : "opacity 300ms linear",
}}

The check is the media query (min-width: 768px) and (hover: hover) and (pointer: fine). The follow also stays off when pointerType is touch.

It also skips the lag when the operating system preference for reduced motion is on. Every circle is placed on the pointer, so the blob sits directly under it and the tail does not stretch. With that preference, the color disappears as soon as the pointer leaves the image.

Otherwise, after the pointer leaves the image, the color layer fades out over 300ms. While the color is showing, its opacity is 0.82.

See the effect on Magic Link Sign-in

You can see the finished motion on the right half of Magic Link Sign-in. Move the mouse over the dots and color appears only inside the blob. Leave the image and the color fades out.

The sign-in form on the left is separate from this effect. It is not part of the mask.

Related guides