Paint Reveal

Hover Image Reveal for React

Two pictures in one frame. The pointer paints the second one in with a soft brush, and the stroke closes back behind it.

  • Image
  • Hover
  • Canvas

Uses clsx, tailwind-merge

Inspired by Lando Norris

Open in ChatGPTOpen in Claude
brushSize180px
softness0.50
fadeMs600ms
lagMs40ms
swell0.20
<PaintReveal />

The demo follows as you drag.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Paint Reveal: Two pictures in one frame. The pointer paints the second one in with a soft brush, and the stroke closes back behind it.
This demo, Studio Hero: A brand studio's header over ink in water. The ink waits in black and white; moving through it paints the color in, and the stroke closes back over about half a second. On a phone the brush drifts by itself. The nav links stay clickable over the picture.

1. Install it:
   npx shadcn@latest add @keyframeui/paint-reveal-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/paint-reveal-demo.json instead.)
   It adds the demo, components/paint-reveal-demo.tsx, and the component, components/ui/paint-reveal.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <PaintReveal> on its own.

3. These props set its feel. Change them before you change the file:
   - brushSize (default 180): Diameter of the brush, in px. A quick stroke paints up to `swell` wider.
   - softness (default 0.5): Edge of the brush, from `0` (crisp) to `1` (very soft). Strokes are drawn as one shape, so overlaps never build up into darker spots.
   - fadeMs (default 600): How long a stroke takes to close back, in ms. It holds its width at first, then thins toward the tail. `0` leaves no trail, just a spotlight under the pointer; `Infinity` keeps the paint until the next flip.
   - lagMs (default 40): How far the brush trails behind the pointer, in ms. Raise it for a looser, smoother stroke that rounds off quick turns.
   - swell (default 0.2): How much wider a quick stroke paints, as a share of `brushSize`. `0` keeps every stroke the same width.

4. Don't change, in components/ui/paint-reveal.tsx:
   - The brush, the stroke and the flood live in `createPainter`, outside React, on one rAF loop that stops when nothing moves; props reach it through `set()`, never a re-render per frame.
   - Every dab fills the mask as one shadow-feathered shape, so overlapping dabs never stack into darker spots and a stroke's edge stays as soft as a resting brush.
   - The canvas redraws `object-fit: cover` at `objectPosition` by hand, so the paint lines up pixel for pixel with the `<img>` beneath it.
   - A flip floods out from the brush or the pressed button, then swaps the base picture; a resting pointer's brush stays shut until it moves again (`armed`).
   - Under reduced motion there's no brush or drift: the toggle always shows and a flip crossfades the whole frame.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/paint-reveal.md

Installation

Add the component on its own with the CLI, or copy the file in by hand.

The CLI writes components/ui/paint-reveal.tsx and installs clsx and tailwind-merge. It needs the @keyframeui registry in components.json; add it once per project.

npx shadcn@latest add @keyframeui/paint-reveal

Examples

Finished sections built with Paint Reveal. Each one installs whole, with the component included.

Photo Restore

An AI photo-restoration tool. With `fadeMs={Infinity}` the paint stays, so you restore the print stroke by stroke. "Restored" floods the rest in from the switch, and "Faded" floods it back and starts over.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Paint Reveal: Two pictures in one frame. The pointer paints the second one in with a soft brush, and the stroke closes back behind it.
This demo, Photo Restore: An AI photo-restoration tool. With `fadeMs={Infinity}` the paint stays, so you restore the print stroke by stroke. "Restored" floods the rest in from the switch, and "Faded" floods it back and starts over.

1. Install it:
   npx shadcn@latest add @keyframeui/paint-reveal-restore-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/paint-reveal-restore-demo.json instead.)
   It adds the demo, components/paint-reveal-restore-demo.tsx, and the component, components/ui/paint-reveal.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <PaintReveal> on its own.

3. These props set its feel. Change them before you change the file:
   - brushSize (default 180): Diameter of the brush, in px. A quick stroke paints up to `swell` wider.
   - softness (default 0.5): Edge of the brush, from `0` (crisp) to `1` (very soft). Strokes are drawn as one shape, so overlaps never build up into darker spots.
   - fadeMs (default 600): How long a stroke takes to close back, in ms. It holds its width at first, then thins toward the tail. `0` leaves no trail, just a spotlight under the pointer; `Infinity` keeps the paint until the next flip.
   - lagMs (default 40): How far the brush trails behind the pointer, in ms. Raise it for a looser, smoother stroke that rounds off quick turns.
   - swell (default 0.2): How much wider a quick stroke paints, as a share of `brushSize`. `0` keeps every stroke the same width.

4. Don't change, in components/ui/paint-reveal.tsx:
   - The brush, the stroke and the flood live in `createPainter`, outside React, on one rAF loop that stops when nothing moves; props reach it through `set()`, never a re-render per frame.
   - Every dab fills the mask as one shadow-feathered shape, so overlapping dabs never stack into darker spots and a stroke's edge stays as soft as a resting brush.
   - The canvas redraws `object-fit: cover` at `objectPosition` by hand, so the paint lines up pixel for pixel with the `<img>` beneath it.
   - A flip floods out from the brush or the pressed button, then swaps the base picture; a resting pointer's brush stays shut until it moves again (`armed`).
   - Under reduced motion there's no brush or drift: the toggle always shows and a flip crossfades the whole frame.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/paint-reveal.md

About the Founder

A studio's about section. With `autoPlay`, the brush drifts over the portrait by itself until the pointer takes over, so the color keeps moving through it while you read.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Paint Reveal: Two pictures in one frame. The pointer paints the second one in with a soft brush, and the stroke closes back behind it.
This demo, About the Founder: A studio's about section. With `autoPlay`, the brush drifts over the portrait by itself until the pointer takes over, so the color keeps moving through it while you read.

1. Install it:
   npx shadcn@latest add @keyframeui/paint-reveal-founder-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/paint-reveal-founder-demo.json instead.)
   It adds the demo, components/paint-reveal-founder-demo.tsx, and the component, components/ui/paint-reveal.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <PaintReveal> on its own.

3. These props set its feel. Change them before you change the file:
   - brushSize (default 180): Diameter of the brush, in px. A quick stroke paints up to `swell` wider.
   - softness (default 0.5): Edge of the brush, from `0` (crisp) to `1` (very soft). Strokes are drawn as one shape, so overlaps never build up into darker spots.
   - fadeMs (default 600): How long a stroke takes to close back, in ms. It holds its width at first, then thins toward the tail. `0` leaves no trail, just a spotlight under the pointer; `Infinity` keeps the paint until the next flip.
   - lagMs (default 40): How far the brush trails behind the pointer, in ms. Raise it for a looser, smoother stroke that rounds off quick turns.
   - swell (default 0.2): How much wider a quick stroke paints, as a share of `brushSize`. `0` keeps every stroke the same width.

4. Don't change, in components/ui/paint-reveal.tsx:
   - The brush, the stroke and the flood live in `createPainter`, outside React, on one rAF loop that stops when nothing moves; props reach it through `set()`, never a re-render per frame.
   - Every dab fills the mask as one shadow-feathered shape, so overlapping dabs never stack into darker spots and a stroke's edge stays as soft as a resting brush.
   - The canvas redraws `object-fit: cover` at `objectPosition` by hand, so the paint lines up pixel for pixel with the `<img>` beneath it.
   - A flip floods out from the brush or the pressed button, then swaps the base picture; a resting pointer's brush stays shut until it moves again (`armed`).
   - Under reduced motion there's no brush or drift: the toggle always shows and a flip crossfades the whole frame.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/paint-reveal.md

Work Grid

A portfolio grid in grayscale, with a smaller brush on each card. Only the card under the pointer draws anything, and `autoPlay={false}` keeps the grid still on phones.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Paint Reveal: Two pictures in one frame. The pointer paints the second one in with a soft brush, and the stroke closes back behind it.
This demo, Work Grid: A portfolio grid in grayscale, with a smaller brush on each card. Only the card under the pointer draws anything, and `autoPlay={false}` keeps the grid still on phones.

1. Install it:
   npx shadcn@latest add @keyframeui/paint-reveal-work-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/paint-reveal-work-demo.json instead.)
   It adds the demo, components/paint-reveal-work-demo.tsx, and the component, components/ui/paint-reveal.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <PaintReveal> on its own.

3. These props set its feel. Change them before you change the file:
   - brushSize (default 180): Diameter of the brush, in px. A quick stroke paints up to `swell` wider.
   - softness (default 0.5): Edge of the brush, from `0` (crisp) to `1` (very soft). Strokes are drawn as one shape, so overlaps never build up into darker spots.
   - fadeMs (default 600): How long a stroke takes to close back, in ms. It holds its width at first, then thins toward the tail. `0` leaves no trail, just a spotlight under the pointer; `Infinity` keeps the paint until the next flip.
   - lagMs (default 40): How far the brush trails behind the pointer, in ms. Raise it for a looser, smoother stroke that rounds off quick turns.
   - swell (default 0.2): How much wider a quick stroke paints, as a share of `brushSize`. `0` keeps every stroke the same width.

4. Don't change, in components/ui/paint-reveal.tsx:
   - The brush, the stroke and the flood live in `createPainter`, outside React, on one rAF loop that stops when nothing moves; props reach it through `set()`, never a re-render per frame.
   - Every dab fills the mask as one shadow-feathered shape, so overlapping dabs never stack into darker spots and a stroke's edge stays as soft as a resting brush.
   - The canvas redraws `object-fit: cover` at `objectPosition` by hand, so the paint lines up pixel for pixel with the `<img>` beneath it.
   - A flip floods out from the brush or the pressed button, then swaps the base picture; a resting pointer's brush stays shut until it moves again (`armed`).
   - Under reduced motion there's no brush or drift: the toggle always shows and a flip crossfades the whole frame.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/paint-reveal.md

Props

src Required

Typestring

The picture shown at rest.

alt Required

Typestring

Alt text for src.

revealSrc Required

Typestring

The picture the brush paints in. Give it the same size and framing as src so the two line up. Any URL works: it's drawn to a canvas but never read back, so it needs no CORS headers.

revealAlt

TypestringDefault""

Alt text for revealSrc. Leave it empty when it only restyles src.

srcSet

Typestring

Responsive candidates for src, as in <img srcSet>.

revealSrcSet

Typestring

Responsive candidates for revealSrc. Offer the same widths as srcSet, so the two still line up.

sizes

Typestring

How wide the frame is drawn, as in <img sizes>, so the browser picks the smallest picture that stays sharp.

loading

Type"eager" | "lazy"

"lazy" waits to fetch both pictures until the frame nears the screen. Leave it unset for a frame at the top of the page.

brushSize

TypenumberDefault180

Diameter of the brush, in px. A quick stroke paints up to swell wider.

softness

TypenumberDefault0.5

Edge of the brush, from 0 (crisp) to 1 (very soft). Strokes are drawn as one shape, so overlaps never build up into darker spots.

fadeMs

TypenumberDefault600

How long a stroke takes to close back, in ms. It holds its width at first, then thins toward the tail. 0 leaves no trail, just a spotlight under the pointer; Infinity keeps the paint until the next flip.

lagMs

TypenumberDefault40

How far the brush trails behind the pointer, in ms. Raise it for a looser, smoother stroke that rounds off quick turns.

swell

TypenumberDefault0.2

How much wider a quick stroke paints, as a share of brushSize. 0 keeps every stroke the same width.

autoPlay

Typeboolean | "touch"Default"touch"

Let the brush drift over the frame by itself while it's in view. "touch" does it only on screens without hover, true also on desktop while the pointer is elsewhere, false never. A finger drag or the pointer takes over.

revealed

Typeboolean

Floods revealSrc over the whole frame, from the brush, the toggle or the center. After that the brush paints src back. Leave unset to let the toggle manage it.

defaultRevealed

TypebooleanDefaultfalse

Whether revealSrc starts out covering the frame.

onRevealedChange

Type(revealed: boolean) => void

Called when the toggle flips the pictures.

toggle

TypebooleanDefaultfalse

Show a two-way switch in the bottom-right corner. It's always shown with reduced motion, where the brush is off and the switch crossfades.

labels

Type[string, string]Default["Before", "After"]

The switch's labels: src first, then revealSrc.

toggleClassName

Typestring

Classes for the switch, e.g. top-3 bottom-auto to move it to the top-right corner.

objectPosition

TypestringDefault"50% 50%"

Where both pictures are anchored when they're cropped, like CSS object-position. Takes keywords and percentages.

children

TypeReact.ReactNode

Content laid over the pictures, like a headline. It doesn't block the brush, and in-flow content can set the frame's height.

className

Typestring

Classes for the frame. Give it a size here (aspect-[3/2], h-[80svh]) unless its children set one. Touch screens can still scroll the page through it vertically; add touch-none to paint in every direction instead.