Inverting Blend Cursor
A round cursor inverts whatever it passes over and grows into a lens when it reaches a link.
Look closer
View case study →Create a custom React cursor that inverts the content under it. Inside the area, hide the native cursor (cursor: none, only when (pointer: fine)) and render a 20px white circle with position: absolute, pointer-events: none and mix-blend-mode: difference, so it inverts text and backgrounds beneath it. On pointermove, set its transform to translate(x, y) translate(-50%, -50%) directly (no lag). When the pointer is over an element with data-cursor="grow", scale the circle to 4 over 250ms with cubic-bezier(0.16, 1, 0.3, 1). Hide it on pointerleave. Keep keyboard focus styles visible because the custom cursor does nothing for keyboard users. Under prefers-reduced-motion, keep the inversion but skip the scale transition. Content: the headline "Look closer" and a link "View case study".
Source
'use client'
import { useRef } from 'react'
import s from './demo.module.css'
export default function BlendCursor({ labels }: { labels: Record<string, string> }) {
const dot = useRef<HTMLSpanElement>(null)
const onMove = (e: React.PointerEvent<HTMLDivElement>) => {
if (e.pointerType === 'touch' || !dot.current) return
const r = e.currentTarget.getBoundingClientRect()
const grow = (e.target as HTMLElement).closest('[data-cursor="grow"]') !== null
dot.current.style.transform = `translate(${e.clientX - r.left}px, ${e.clientY - r.top}px) translate(-50%, -50%)`
dot.current.dataset.grow = String(grow)
dot.current.dataset.on = 'true'
}
return (
<div className={s.area} onPointerMove={onMove} onPointerLeave={() => dot.current && (dot.current.dataset.on = 'false')}>
<p className={s.text}>{labels.text}</p>
<a className={s.link} href="#" data-cursor="grow" onClick={(e) => e.preventDefault()}>
{labels.link} →
</a>
<span ref={dot} className={s.cursor} aria-hidden="true">
<span className={s.lens} />
</span>
</div>
)
}
.area {
--lens: oklch(100% 0 0);
position: absolute;
inset: 0;
display: grid;
place-content: center;
justify-items: center;
gap: 14px;
overflow: hidden;
}
@media (pointer: fine) {
.area, .area * { cursor: none; }
}
.text {
margin: 0;
font: 700 2.4rem / 1 var(--font-display);
letter-spacing: -0.03em;
color: var(--stage-ink);
white-space: nowrap;
}
.link {
padding: 10px 16px;
border-radius: 999px;
background: var(--stage-accent);
color: var(--stage-accent-ink);
font: 600 var(--text-sm) / 1 var(--font-body);
text-decoration: none;
white-space: nowrap;
}
.link:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 3px; }
.cursor {
position: absolute;
top: 0;
left: 0;
pointer-events: none;
mix-blend-mode: difference;
opacity: 0;
}
.cursor[data-on='true'] { opacity: 1; }
.lens {
display: block;
width: 20px;
height: 20px;
border-radius: 50%;
background: var(--lens);
transition: transform 250ms var(--ease-out);
}
.cursor[data-grow='true'] .lens { transform: scale(4); }
@media (prefers-reduced-motion: reduce) {
.lens { transition: none; }
}