reveal-hover-effect
What it does
This skill builds an image hover effect in which a soft circle around the pointer shows a second, aligned picture. It is for designers and developers making product detail, before and after, or material comparison views.
When to use it
- ✓When you want visitors to hover over an image and see a color or texture version of it.
- ✓When you need a before and after comparison that follows the mouse.
- ✓When a product page should show an x-ray or material view on hover.
Skill link
https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/reveal-hover-effect/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“I want visitors to hover over my product photo and see a colorful version of it inside a soft circle that follows the cursor.”
5 new skills a week. 1 minute to read.
How it works
The agent stacks two images of the same size, puts a feathered radial mask on the top one, and moves that mask toward the pointer with easing. When the pointer leaves, the circle shrinks away so nothing is left behind.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Reveal Hover Effect
Core Contract
- Prepare two images with identical dimensions, composition, crop, and focal point.
- Keep the base image fully visible.
- Stack the reveal image directly above it.
- Apply a feathered radial
mask-imageto the reveal image. - Track pointer coordinates in the component's local coordinate space.
- Ease the rendered position toward the raw pointer with
requestAnimationFrame. - Collapse the mask on pointer exit; never leave a stale spotlight behind.
Default to CSS masks instead of generating a canvas data URL every frame. The CSS version preserves the same look with less allocation and simpler cleanup.
Motion Defaults
- Desktop spotlight radius:
260px. - Compact spotlight radius:
140pxto220px. - Pointer easing:
0.1. - Radius easing:
0.14. - Mask stops:
0%: alpha140%: alpha160%: alpha0.7575%: alpha0.488%: alpha0.12100%: alpha0
- Initial state: base image only.
- Exit state: radius eases back to
0. - Cursor: keep the native cursor unless the design explicitly needs a custom one.
Markup
Use real images so loading, intrinsic sizing, and accessibility remain predictable.
<figure class="reveal-hover" data-reveal-hover data-reveal-radius="260">
<img
class="reveal-hover__image reveal-hover__image--base"
src="/images/product-linework.webp"
alt="Sculpted product shown in a pale linework treatment"
width="1600"
height="1000"
decoding="async"
/>
<img
class="reveal-hover__image reveal-hover__image--overlay"
src="/images/product-color.webp"
alt=""
width="1600"
height="1000"
decoding="async"
aria-hidden="true"
/>
</figure>
Keep the overlay decorative when both images communicate the same subject. If the comparison carries unique information, provide visible labels or a separate accessible description.
CSS Mask
.reveal-hover {
--reveal-x: 50%;
--reveal-y: 50%;
--reveal-radius: 0px;
position: relative;
overflow: clip;
isolation: isolate;
margin: 0;
background: #f3f1ec;
contain: paint;
}
.reveal-hover__image {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
object-position: center;
}
.reveal-hover__image--base {
position: relative;
z-index: 0;
}
.reveal-hover__image--overlay {
position: absolute;
z-index: 1;
inset: 0;
pointer-events: none;
-webkit-mask-image: radial-gradient(
circle var(--reveal-radius) at var(--reveal-x) var(--reveal-y),
rgb(0 0 0 / 1) 0%,
rgb(0 0 0 / 1) 40%,
rgb(0 0 0 / 0.75) 60%,
rgb(0 0 0 / 0.4) 75%,
rgb(0 0 0 / 0.12) 88%,
transparent 100%
);
mask-image: radial-gradient(
circle var(--reveal-radius) at var(--reveal-x) var(--reveal-y),
rgb(0 0 0 / 1) 0%,
rgb(0 0 0 / 1) 40%,
rgb(0 0 0 / 0.75) 60%,
rgb(0 0 0 / 0.4) 75%,
rgb(0 0 0 / 0.12) 88%,
transparent 100%
);
-webkit-mask-repeat: no-repeat;
mask-repeat: no-repeat;
will-change: -webkit-mask-image, mask-image;
}
@media (hover: none), (pointer: coarse) {
.reveal-hover__image--overlay {
display: none;
}
}
Keep object-fit and object-position identical on both layers. A one-pixel mismatch becomes obvious inside the spotlight.
Eased Pointer Tracking
Run the animation loop only while values are changing. Convert clientX and clientY with getBoundingClientRect(); page coordinates will drift after scroll.
function initRevealHover(element) {
const overlay = element.querySelector(".reveal-hover__image--overlay");
const finePointer = window.matchMedia("(hover: hover) and (pointer: fine)");
const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)");
if (!overlay || !finePointer.matches) return () => {};
const state = {
x: 0,
y: 0,
targetX: 0,
targetY: 0,
radius: 0,
targetRadius: 0,
clientX: 0,
clientY: 0,
inside: false,
frame: 0,
};
const getRadius = () => {
const requested = Number.parseFloat(element.dataset.revealRadius);
if (Number.isFinite(requested)) return requested;
return Math.min(260, Math.max(140, element.clientWidth * 0.22));
};
const updateTarget = (clientX, clientY) => {
const rect = element.getBoundingClientRect();
state.clientX = clientX;
state.clientY = clientY;
state.targetX = clientX - rect.left;
state.targetY = clientY - rect.top;
};
const schedule = () => {
if (!state.
FAQ
Do the two images need to match?
Yes. The skill requires identical dimensions, crop, and focal point so they line up.
Does it draw on a canvas each frame?
No. It uses CSS masks by default, which is lighter and easier to clean up.
Does it hide the normal cursor?
No. It keeps the native cursor unless the design calls for a custom one.
Details
Original description by the author
Build cursor-following spotlight reveals that expose a second aligned image through a soft radial mask. Use for hover-to-color, before-and-after, x-ray, material, texture, product-detail, and illustrated hero effects where a desaturated or embossed base image should remain visible while another treatment follows an eased pointer.
repo: MengTo/Skills
Popularity
- GitHub stars
- 7.2k
- Ranking position
- #13461
- License
- MIT
- Updated
- 11/1/2026
Comments
- …
More skills from this repository
3d-cloth-material
7.2kHelps your agent build realistic woven fabric in Three.js, with thread weave, soft sheen, natural folds, hems and seams.
3d-falling-leaves
7.2kHelps your agent add realistic falling leaves to a 3D scene, with leaves that tumble, drift with the wind and recycle as the camera moves.
3d-four-seasons
7.2kHelps your agent add spring, summer, fall and winter looks to a 3D scene, changing foliage, light, sky and snow without rebuilding it.
3d-high-poly-models
7.2kHelps your agent build detailed 3D models with smooth shapes and believable edges, then prepare lighter versions that run well on the web.
Similar skills
canvas
394kLets your agent show a hosted visual widget on a connected Mac panel, then hide the panel or move it to another page.
control-ui
394kHelps your agent organize and troubleshoot the OpenClaw Control UI, including sessions, dashboards, and connected Gateways.
diagram-maker
394kHelps your agent create clear diagrams as SVG, HTML, or editable Excalidraw files for processes, system architecture, and whiteboard sketches.