December 4, 2026
To make a custom cursor, add a small fixed element to the page, store the pointer position on pointermove, and move
the element to that position every animation frame with a transform. A second, larger ring that only covers part of the
remaining distance each frame gives the trailing effect. The free Enrichr Library has five finished
cursors to copy.
What is the basic pattern?
<div class="cur-dot"></div>
<div class="cur-ring"></div>
.cur-dot, .cur-ring {
position: fixed; left: 0; top: 0;
border-radius: 50%;
pointer-events: none; /* never block clicks */
z-index: 9999;
display: none;
}
.cur-dot { width: 8px; height: 8px; margin: -4px; background: #111; }
.cur-ring { width: 36px; height: 36px; margin: -18px; border: 1px solid #111;
transition: scale 0.2s; }
.cur-ring.is-link { scale: 1.6; }
@media (hover: hover) and (pointer: fine) {
.cur-dot, .cur-ring { display: block; }
}
const dot = document.querySelector(".cur-dot");
const ring = document.querySelector(".cur-ring");
let x = 0, y = 0, rx = 0, ry = 0;
addEventListener("pointermove", (e) => { x = e.clientX; y = e.clientY; });
addEventListener("pointerover", (e) => {
ring.classList.toggle("is-link", !!e.target.closest("a, button"));
});
(function frame() {
rx += (x - rx) * 0.15; // the ring covers 15% of the gap each frame
ry += (y - ry) * 0.15;
dot.style.transform = `translate3d(${x}px, ${y}px, 0)`;
ring.style.transform = `translate3d(${rx}px, ${ry}px, 0)`;
requestAnimationFrame(frame);
})();
The line rx += (x - rx) * 0.15 is a lerp. A smaller number gives a lazier ring. A larger one makes it stick to the
dot.
How do I make the cursor invert what is under it?
Give the dot a white background and mix-blend-mode: difference. White in difference mode flips every colour
beneath it, so the cursor stays visible on light and dark sections alike.
Which finished cursors can I copy?
| Element | What it does |
|---|---|
| Cursor follower states | A dot and lagging ring that grows over links and shows a label on cards and sliders. |
| Blend mode cursor | A dot that inverts what is beneath it and grows over links, for fine pointers only. |
| Jiggle cursor dot | A see-through dot that wobbles like jelly when you move fast. |
| Invert ripple cursor | A big circle that inverts everything beneath it, with a rippling edge. |
| Refractive glass lens | A glass lens that follows the pointer and bends the page behind it. |
When should I not use a custom cursor?
- Touch screens. There is no pointer to follow. The media query above keeps the elements hidden.
- Forms and long text. Keep the system caret and text cursor there.
- Reduced motion. If the visitor asks for less motion, drop the lagging ring or the whole effect.
If you hide the real cursor with cursor: none, do it only inside the same media query, so a failed script never
leaves the visitor with no cursor at all.
Where to go next
- How to make an image trail that follows the cursor.
- How to make a magnetic button.
- What to do with animations when a visitor asks for reduced motion.
FAQ
How do I make a custom cursor that follows the mouse?
Add a small fixed element, listen for pointermove to store the pointer position, and on each animation frame move the element toward that position with a CSS transform.
Why does my custom cursor lag or stutter?
You are probably animating left and top, or using a CSS transition on every mouse event. Move it with transform: translate3d() inside requestAnimationFrame instead.
Can I just use the CSS cursor property?
Yes, for a static image: cursor: url(cursor.png) 8 8, auto. The numbers set the hot spot. It cannot animate or react to what is under it, which is why sites use an element instead.
Should I hide the real cursor?
Only where your own cursor is running, and never on text fields. People need the text caret to see where they are typing.