Inverted Blend Cursor

A circle cursor that inverts whatever sits under it with mix-blend-mode, and grows when it crosses a link.


Inverted Blend Cursor


mix-blend-mode: difference turns a white circle into a negative of the pixels underneath. The blend has to live on the same element that moves. A transformed parent isolates its children, so a nested circle stays solid white and never inverts the type.

Related: label cursor, cursor effects, stardust trail, and the custom cursor tutorial.

HTML

<div class="blend-cursor" id="blendCursor"></div>

CSS

.blend-cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 20;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  border-radius: 50%;
  background: #fff;
  mix-blend-mode: difference;
  pointer-events: none;
  scale: 1;
  transition: scale 0.2s ease;
}
.blend-cursor.is-hot { scale: 1.65; }
@media (pointer: coarse) {
  .blend-cursor { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .blend-cursor { transition: none; }
}

JavaScript

const cursor = document.getElementById("blendCursor");
const fine = window.matchMedia("(pointer: fine)").matches;
if (cursor && fine) {
  document.body.classList.add("has-blend-cursor");
  window.addEventListener("pointermove", (event) => {
    cursor.style.translate = `${event.clientX}px ${event.clientY}px`;
    const hot = event.target.closest("a, button");
    cursor.classList.toggle("is-hot", Boolean(hot));
  });
}
body.has-blend-cursor, body.has-blend-cursor a, body.has-blend-cursor button { cursor: none; }

Difference blend needs a solid color behind the circle. A fully transparent page background will not invert.