Custom Cursor Effects in CSS and JavaScript
Updated 2026-10-15. 13 effects.
A custom cursor effect draws an extra element that follows the pointer, such as a ring, a trail or a spotlight, while the real cursor keeps working. You move it with transform inside a requestAnimationFrame loop, smooth it with a little easing, and switch it off on touch screens and for reduced motion.
Treat the effect as an accent for one area, not the whole site. A soft follower ring that grows over links helps a portfolio grid feel responsive; a label cursor that reads View or Drag tells people what a click will do; trails and spotlights belong on a hero or a playful landing section where nobody needs to fill in a form.
Each snippet listens on its own section rather than the whole window, so you can drop it into one block of a page. The system pointer is only hidden on devices with a precise mouse, and the decoration steps aside whenever a control receives keyboard focus, so nobody loses track of where they are.
Compare them
| Effect | Built with | Size (gzipped) | Running cost | Browser support |
|---|---|---|---|---|
| Ink Dot Cursor Trail | CSS and a small script | 2.8 KB | Twenty small elements moved with transform in one frame loop that stops when the hero is off screen. | All current browsers |
| Blueprint Compass Marks Trailing the Cursor | CSS and a small script | 2.8 KB | Twelve cloned SVGs animated with transform and opacity; the loop only checks distance and pauses off screen. | All current browsers |
| Chalk Dust Cursor Trail | Canvas 2D | 2.6 KB | Up to five hundred one-pixel rectangles per frame from a fixed pool; the loop pauses off screen and stops once a tap puff settles. | All current browsers |
| Comet Cursor Trail on Canvas | Canvas 2D | 2.4 KB | About thirty short line strokes and one small gradient per frame on a canvas capped at 2x pixel ratio, stopped off screen. | All current browsers |
| Context Cursor With Caret and Ring | CSS and a small script | 2.6 KB | One element moved with transform plus a short opacity blink; the loop and blink pause off screen. | All current browsers |
| Difference Blend Dot Cursor | CSS and a small script | 2 KB | One element moved with transform; the blend is done by the compositor, though a very large disc does cost a little more to blend. | All current browsers |
| Eased Ring Cursor That Snaps to Links | CSS and a small script | 2.6 KB | Two elements moved with transform in one frame loop, plus one rectangle read per frame while snapped; paused off screen. | All current browsers |
| Grid Tiles Light Up Under the Pointer | CSS and a small script | 2.4 KB | A few hundred tiles on a wide screen, but only those whose glow changed get an opacity write each frame; the loop pauses off screen. | All current browsers |
| Label Cursor for View, Drag and Play | CSS and a small script | 3.4 KB | One element moved with transform and a rectangle read per frame; the loop stops off screen. | All current browsers |
| Magnifier Loupe Over a Price List | CSS and a small script | 2.8 KB | Two elements moved with transform per frame, though the scaled copy doubles the text the browser keeps in memory. | All current browsers |
| Pointer Spotlight Over a Dimmed Photo | CSS and a small script | 2.1 KB | A single gradient layer moved with transform, so the gradient is painted once and only composited after that. | All current browsers |
| Precision Crosshair With Coordinate Readout | CSS and a small script | 2.8 KB | Five small elements moved with transform and one text update per move; the idle loop stops for real input and off screen. | All current browsers |
| Spring Chain Ribbon Trail | CSS and a small script | 2.7 KB | Twenty-three transforms per frame from a tiny spring loop; it stops when the section leaves the screen. | All current browsers |
Ink Dot Cursor Trail
A chain of twenty small ink dots chases the pointer across a cream paper hero for a made-up stationery shop. Each dot eases toward the one in front, shrinking and thinning as it goes, so a quick flick of the mouse leaves a tapering stroke that settles back into a single pen tip. The dots travel under the headline and buttons, so copy stays crisp. Before anyone moves a mouse, the trail traces a slow figure of eight so the preview never sits still.
<section class="w2ink-root" data-w2ink>
<div class="w2ink-layer" aria-hidden="true"></div>
<span class="w2ink-blot" aria-hidden="true"></span>
<div class="w2ink-wrap">
<nav class="w2ink-nav" aria-label="Marlow and Finch">
<a href="#" class="w2ink-brand">Marlow & Finch</a>
<ul>
<li><a href="#">Notebooks</a></li>
<li><a href="#">Ink</a></li>
<li><a href="#">Workshop</a></li>
</ul>
</nav>
<div class="w2ink-hero">
<p class="w2ink-eyebrow">Spring stock, bound by hand</p>
<h1>Paper that holds a thought until you are ready for it.</h1>
<p class="w2ink-lede">Notebooks and letter sets cut from heavy cotton stock, sewn in small runs and sent out wrapped in plain brown paper.</p>
<div class="w2ink-ctas">
<a href="#" class="w2ink-btn">Browse the notebooks</a>
<a href="#" class="w2ink-btn w2ink-ghost">Visit the shop</a>
</div>
</div>
<dl class="w2ink-notes">
<div><dt>Paper</dt><dd>120 gsm cream, fountain pen safe</dd></div>
<div><dt>Binding</dt><dd>Thread sewn, opens flat</dd></div>
<div><dt>Made in</dt><dd>A two-room bindery by the canal</dd></div>
</dl>
</div>
</section>
<style>
/* Change these: --w2ink-ink (trail and text colour), --w2ink-accent (labels and focus), --w2ink-dot (dot size). */
.w2ink-root { --w2ink-ink: #1d2433; --w2ink-accent: #8a4b2a; --w2ink-dot: 14px;
position: relative; overflow: hidden; padding: 56px 20px; color: var(--w2ink-ink); font-family: system-ui, sans-serif;
background: radial-gradient(120% 90% at 20% 0%, #fbf7ef 0%, #f1e9da 60%, #e9dfcc 100%); }
@media (min-width: 640px) { .w2ink-root { padding: 80px 40px; } }
.w2ink-wrap { position: relative; z-index: 1; max-width: 64rem; margin: 0 auto; }
.w2ink-nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; font-size: .875rem; }
.w2ink-nav ul { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; }
.w2ink-nav ul a { display: inline-flex; min-height: 40px; align-items: center; padding: 0 12px; color: #4a4f5c; text-decoration: none; border-radius: 4px; }
.w2ink-brand { font-family: Georgia, "Times New Roman", serif; font-size: 1.125rem; font-weight: 600; color: inherit; text-decoration: none; border-radius: 4px; }
.w2ink-hero { margin-top: 56px; max-width: 42rem; }
@media (min-width: 640px) { .w2ink-hero { margin-top: 80px; } }
.w2ink-eyebrow { margin: 0; font-size: .75rem; font-weight: 600; letter-spacing: .24em; text-transform: uppercase; color: var(--w2ink-accent); }
.w2ink-hero h1 { margin: 16px 0 0; font-family: Georgia, "Times New Roman", serif; font-weight: 400; font-size: clamp(2.25rem, 6vw, 3.75rem); line-height: 1.08; letter-spacing: -.02em; }
.w2ink-lede { margin: 24px 0 0; max-width: 36rem; font-size: 1.0625rem; line-height: 1.65; color: #4a4f5c; }
.w2ink-ctas { margin-top: 32px; display: flex; flex-wrap: wrap; gap: 12px; }
.w2ink-btn { display: inline-flex; min-height: 44px; align-items: center; padding: 0 24px; border-radius: 999px; font-size: .875rem; font-weight: 600;
text-decoration: none; background: var(--w2ink-ink); color: #f6f1e7; box-shadow: 0 8px 24px -12px rgba(29,36,51,.6); }
.w2ink-ghost { background: #fbf8f2; color: var(--w2ink-ink); border: 1px solid rgba(29,36,51,.25); box-shadow: none; }
.w2ink-root a:focus-visible { outline: 2px solid var(--w2ink-accent); outline-offset: 3px; }
.w2ink-notes { margin: 56px 0 0; padding-top: 24px; border-top: 1px solid rgba(29,36,51,.15); display: grid; gap: 24px; }
@media (min-width: 640px) { .w2ink-notes { grid-template-columns: repeat(3, 1fr); } }
.w2ink-notes dt { font-size: .75rem; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--w2ink-accent); }
.w2ink-notes dd { margin: 4px 0 0; font-size: .875rem; color: #3a3f4c; }
.w2ink-layer { position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: 0; transition: opacity .4s ease; }
.w2ink-root[data-on] .w2ink-layer { opacity: 1; }
.w2ink-root[data-kb] .w2ink-layer { opacity: 0; }
.w2ink-dot { position: absolute; left: calc(var(--w2ink-dot) / -2); top: calc(var(--w2ink-dot) / -2); width: var(--w2ink-dot); height: var(--w2ink-dot);
border-radius: 50%; background: radial-gradient(circle at 38% 35%, #3b4a6b 0%, #1b2540 70%); will-change: transform; }
.w2ink-blot { position: absolute; left: -30px; top: -30px; width: 60px; height: 60px; border-radius: 50%; opacity: 0; pointer-events: none;
background: radial-gradient(circle, rgba(27,37,64,.35) 0%, rgba(27,37,64,0) 70%); }
.w2ink-blot.w2ink-go { animation: w2ink-spread .9s ease-out forwards; }
@keyframes w2ink-spread { from { opacity: 1; scale: .3 } to { opacity: 0; scale: 1.6 } }
@media (prefers-reduced-motion: reduce) { .w2ink-layer, .w2ink-blot { display: none; } }
</style>
<script>
(function () {
var root = document.querySelector("[data-w2ink]");
if (!root) return;
var DOTS = 20; // how many ink dots make up the trail
var HEAD = 0.26; // how quickly the first dot catches the pointer (0 to 1)
var TAIL = 0.3; // how tightly each dot follows the one ahead
if (matchMedia("(prefers-reduced-motion: reduce)").matches) return;
var layer = root.querySelector(".w2ink-layer");
if (!matchMedia("(hover: hover) and (pointer: fine)").matches) {
// Touch: a tap leaves a soft ink blot instead of a trail.
var blot = root.querySelector(".w2ink-blot");
root.addEventListener("pointerdown", function (e) {
var r = root.getBoundingClientRect();
blot.style.transform = "translate(" + (e.clientX - r.left) + "px," + (e.clientY - r.top) + "px)";
blot.classList.remove("w2ink-go"); void blot.offsetWidth; blot.classList.add("w2ink-go");
});
return;
}
var dots = [], pts = [];
for (var i = 0; i < DOTS; i++) {
var d = document.createElement("span");
d.className = "w2ink-dot";
d.style.opacity = 0.9 - (i / DOTS) * 0.8;
layer.appendChild(d); dots.push(d); pts.push({ x: -50, y: -50 });
}
root.setAttribute("data-on", "");
var tx = 0, ty = 0, live = false, frame = 0, idle = 0, t0 = performance.now();
function loop(now) {
if (!live) {
var t = (now - t0) / 1000;
tx = root.clientWidth * (0.5 + 0.34 * Math.sin(t * 0.85));
ty = root.clientHeight * (0.52 + 0.24 * Math.sin(t * 1.7));
}
for (var i = 0; i < DOTS; i++) {
var p = pts[i], lx = i ? pts[i - 1].x : tx, ly = i ? pts[i - 1].y : ty, k = i ? TAIL : HEAD;
p.x += (lx - p.x) * k; p.y += (ly - p.y) * k;
dots[i].style.transform = "translate(" + p.x + "px," + p.y + "px) scale(" + (1 - i / DOTS * 0.82) + ")";
}
frame = requestAnimationFrame(loop);
}
function start() { if (!frame) frame = requestAnimationFrame(loop); }
function stop() { cancelAnimationFrame(frame); frame = 0; }
new IntersectionObserver(function (e) { e[0].isIntersecting ? start() : stop(); }).observe(root);
root.addEventListener("pointermove", function (e) {
if (e.pointerType === "touch") return;
var r = root.getBoundingClientRect();
tx = e.clientX - r.left; ty = e.clientY - r.top; live = true;
clearTimeout(idle); root.removeAttribute("data-kb");
});
root.addEventListener("pointerleave", function () {
idle = setTimeout(function () { live = false; t0 = performance.now() - 2000; }, 1400);
});
// Keyboard focus: the trail steps aside so it never sits on a focus ring.
root.addEventListener("focusin", function () { if (root.querySelector(":focus-visible")) root.setAttribute("data-kb", ""); });
root.addEventListener("focusout", function () { root.removeAttribute("data-kb"); });
})();
</script>
With reduced motion: The hero shows complete and still, with no trail and no tap blot.
Running cost: Twenty small elements moved with transform in one frame loop that stops when the hero is off screen.
- Change `DOTS` to make the stroke longer or shorter; around ten feels like a pencil, twenty like a wet brush.
- Raise `TAIL` toward 0.6 for a tight, quick trail, or drop it toward 0.25 for a lazy, drifting one.
- Set `--w2ink-ink` and the two colours in the `.w2ink-dot` gradient to match your own ink, such as a sepia brown or a deep green.
- Edit `--w2ink-dot` to size every dot at once; the trail keeps its taper because each dot scales from that base.
Full page for Ink Dot Cursor Trail
Blueprint Compass Marks Trailing the Cursor
An architecture practice's hero laid out like a drawing sheet: blueprint blue, a fine grid, a border and a title block in the corner. As the pointer travels it stamps small compass roses, each turned to face the direction of travel, which swing into place, hold, then fade like pencil marks rubbed out. A dozen marks are reused in turn, and a slow survey path draws them before anyone arrives.
<section class="w7cmp" data-w7cmp aria-label="Arden Vale Architects">
<div class="w7cmp-marks" aria-hidden="true">
<svg class="w7cmp-mark" viewBox="-30 -30 60 60"><circle r="17" /><circle r="2.2" class="w7cmp-dot" /><path d="M0 -26V-19M0 19V26M-26 0H-19M19 0H26M-12 -12L-9 -9M12 12L9 9M12 -12L9 -9M-12 12L-9 9" /><path d="M0 -15L4 -4L0 -6L-4 -4Z" class="w7cmp-n" /></svg>
</div>
<div class="w7cmp-sheet" aria-hidden="true"></div>
<div class="w7cmp-body">
<p class="w7cmp-eye">Arden Vale Architects</p>
<h2 class="w7cmp-h">Houses drawn around the way you live</h2>
<p class="w7cmp-p">We start with a week of your routines, not a style. Where the morning light lands, where the boots go, which door everyone really uses. The plan follows from that.</p>
<div class="w7cmp-row">
<a class="w7cmp-btn" href="#">Start with a site visit</a>
<a class="w7cmp-ghost" href="#">View drawings</a>
</div>
</div>
<dl class="w7cmp-block">
<div><dt>Drawing</dt><dd>AV-014</dd></div>
<div><dt>Sheet</dt><dd>Ground floor</dd></div>
<div><dt>Scale</dt><dd>1:50</dd></div>
</dl>
</section>
<style>
/* Change these: --w7cmp-paper (blueprint blue), --w7cmp-line (mark and grid colour), --w7cmp-cell (grid size). Spacing and life of marks are in the script. */
.w7cmp { --w7cmp-paper: #1d3a5f; --w7cmp-line: #dce8f5; --w7cmp-cell: 24px;
position: relative; height: 560px; overflow: hidden; color: var(--w7cmp-line); touch-action: pan-y;
background-color: var(--w7cmp-paper);
background-image: linear-gradient(rgba(220,232,245,.07) 1px, transparent 1px), linear-gradient(90deg, rgba(220,232,245,.07) 1px, transparent 1px),
linear-gradient(rgba(220,232,245,.12) 1px, transparent 1px), linear-gradient(90deg, rgba(220,232,245,.12) 1px, transparent 1px);
background-size: var(--w7cmp-cell) var(--w7cmp-cell), var(--w7cmp-cell) var(--w7cmp-cell), calc(var(--w7cmp-cell) * 5) calc(var(--w7cmp-cell) * 5), calc(var(--w7cmp-cell) * 5) calc(var(--w7cmp-cell) * 5);
font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; display: flex; align-items: center; }
.w7cmp-marks { position: absolute; inset: 0; pointer-events: none; }
.w7cmp-mark { position: absolute; left: -48px; top: -48px; width: 96px; height: 96px; opacity: 0; fill: none; stroke: var(--w7cmp-line); stroke-width: 1.3; stroke-linecap: round; will-change: transform, opacity; }
.w7cmp-mark .w7cmp-dot, .w7cmp-mark .w7cmp-n { fill: var(--w7cmp-line); stroke: none; }
.w7cmp-sheet { position: absolute; inset: 14px; border: 1px solid rgba(220,232,245,.35); pointer-events: none; }
.w7cmp-body { position: relative; width: 100%; max-width: 64rem; margin: 0 auto; padding: 28px 32px 90px; }
.w7cmp-eye { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .26em; text-transform: uppercase; color: #a9c3e0; }
.w7cmp-h { margin: 14px 0 0; max-width: 14ch; font-family: Georgia, "Iowan Old Style", serif; font-weight: 400; font-size: clamp(2.2rem, 5.8vw, 4.2rem); line-height: 1.04; letter-spacing: -.02em; color: #f4f8fc; }
.w7cmp-p { margin: 18px 0 0; max-width: 31rem; font-size: 16px; line-height: 1.65; color: #c5d5e7; }
.w7cmp-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.w7cmp-btn, .w7cmp-ghost { display: inline-flex; align-items: center; min-height: 48px; padding: 0 22px; border-radius: 2px; font-weight: 600; font-size: 15px; text-decoration: none; }
.w7cmp-btn { background: #f4f8fc; color: var(--w7cmp-paper); }
.w7cmp-btn:hover { background: #fff; }
.w7cmp-ghost { color: #f4f8fc; border: 1px solid rgba(220,232,245,.5); background: rgba(29,58,95,.6); }
.w7cmp-ghost:hover { border-color: #f4f8fc; }
.w7cmp-btn:focus-visible, .w7cmp-ghost:focus-visible { outline: 3px solid #f2c46b; outline-offset: 3px; }
.w7cmp-block { position: absolute; right: 14px; bottom: 14px; display: flex; margin: 0; border-top: 1px solid rgba(220,232,245,.35); border-left: 1px solid rgba(220,232,245,.35); background: rgba(29,58,95,.85); }
.w7cmp-block div { padding: 8px 14px; border-left: 1px solid rgba(220,232,245,.2); }
.w7cmp-block div:first-child { border-left: 0; }
.w7cmp-block dt { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: #a9c3e0; }
.w7cmp-block dd { margin: 2px 0 0; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
@media (min-width: 720px) { .w7cmp-body { padding: 40px 64px 60px; } }
@media (prefers-reduced-motion: reduce) { .w7cmp .w7cmp-mark:first-child { opacity: .6; left: auto; right: 10%; top: 16%; width: 120px; height: 120px; transform: rotate(18deg); } }
</style>
<script>
(function () {
var root = document.querySelector("[data-w7cmp]");
if (!root) return;
var off = [];
//BODY-START
var GAP = 90, LIFE = 2800, POOL = 12, IDLE_AFTER = 1800; // px between marks, ms each mark lasts, marks reused, ms before the demo resumes
if (matchMedia("(prefers-reduced-motion: reduce)").matches) return;
var layer = root.querySelector(".w7cmp-marks"), tpl = layer.firstElementChild, pool = [tpl], anims = [], k = 0;
for (var i = 1; i < POOL; i++) { var c = tpl.cloneNode(true); layer.appendChild(c); pool.push(c); }
off.push(function () { anims.forEach(function (a) { a.cancel(); }); while (layer.children.length > 1) layer.removeChild(layer.lastChild); });
var lx = -999, ly = -999, real = 0, raf = 0, seen = true;
function mark(x, y, age) {
var n = k++ % POOL, a = Math.atan2(y - ly, x - lx) * 57.3 + 90, base = "translate(" + x.toFixed(1) + "px," + y.toFixed(1) + "px) rotate(" + a.toFixed(1) + "deg)";
if (anims[n]) anims[n].cancel();
anims[n] = pool[n].animate([
{ opacity: 0, transform: base + " scale(.5) rotate(-40deg)" },
{ opacity: .95, transform: base + " scale(1)", offset: .14 },
{ opacity: .7, transform: base + " scale(1)", offset: .5 },
{ opacity: 0, transform: base + " scale(1.08)" }
], { duration: LIFE, easing: "cubic-bezier(.2,.7,.2,1)", fill: "forwards" });
if (age) anims[n].currentTime = age;
lx = x; ly = y;
}
function near(x, y) { if (Math.hypot(x - lx, y - ly) > GAP) mark(x, y, 0); }
function path(t) { return [root.clientWidth * (.62 + .3 * Math.sin(t * .0005)), root.clientHeight * (.48 + .32 * Math.sin(t * .00115 + .6))]; }
var now = performance.now();
for (var j = 6; j > 0; j--) { var q = path(now - j * 520); mark(q[0], q[1], j * 330); }
function tick(t) {
raf = requestAnimationFrame(tick);
if (real && t - real < IDLE_AFTER) return;
var p = path(t); near(p[0], p[1]);
}
function at(e) { var b = root.getBoundingClientRect(); return [e.clientX - b.left, e.clientY - b.top]; }
function move(e) { if (e.pointerType === "touch") return; real = performance.now(); var p = at(e); near(p[0], p[1]); }
function tap(e) { if (e.pointerType !== "touch") return; real = performance.now(); var p = at(e); mark(p[0], p[1], 0); }
function leave() { real = 0; }
root.addEventListener("pointermove", move);
root.addEventListener("pointerdown", tap);
root.addEventListener("pointerleave", leave);
off.push(function () { root.removeEventListener("pointermove", move); root.removeEventListener("pointerdown", tap); root.removeEventListener("pointerleave", leave); });
function play() { if (!raf && seen) raf = requestAnimationFrame(tick); }
function stop() { cancelAnimationFrame(raf); raf = 0; }
var io = new IntersectionObserver(function (e) { seen = e[0].isIntersecting; if (seen) play(); else stop(); });
io.observe(root);
off.push(stop, function () { io.disconnect(); });
play();
//BODY-END
})();
</script>
With reduced motion: A single compass rose rests near the top right of the sheet and nothing follows the pointer.
Running cost: Twelve cloned SVGs animated with transform and opacity; the loop only checks distance and pauses off screen.
- Recolour the sheet with `--w7cmp-paper` and the lines with `--w7cmp-line`; `--w7cmp-cell` sets the grid.
- Space marks with `GAP` and keep them on the sheet longer with `LIFE`.
- Redraw the mark by editing the single SVG inside `.w7cmp-marks`; the script clones whatever is there.
Chalk Dust Cursor Trail
Moving across a café's slate menu board sheds fine chalk dust that drifts down and fades, as if the pointer were a stick of chalk dragged lightly over the surface. Specks come from a fixed pool of a few hundred particles on one canvas, so a long scribble never piles up work. A tap on a phone knocks a small puff loose instead.
<section class="w2chk-root" data-w2chk>
<div class="w2chk-board">
<canvas class="w2chk-cv" aria-hidden="true"></canvas>
<div class="w2chk-copy">
<p class="w2chk-label">Corner Table, Mill Street</p>
<h2>On the board today</h2>
<ul class="w2chk-menu">
<li><span>Leek and potato soup, sourdough</span><b>7</b></li>
<li><span>Smoked mackerel, beetroot, horseradish</span><b>11</b></li>
<li><span>Mushrooms on toast, thyme butter</span><b>9</b></li>
<li><span>Pear and almond tart, cream</span><b>6</b></li>
</ul>
<a href="#" class="w2chk-btn">Book a table for lunch</a>
</div>
</div>
</section>
<style>
/* Change these: --w2chk-slate (board), --w2chk-chalk (text and dust), --w2chk-frame (wooden edge). DUST in the script sets how much falls. */
.w2chk-root { --w2chk-slate: #2c3633; --w2chk-chalk: #f0ede4; --w2chk-frame: #7b5a3c;
background: #d9cfbf; padding: 40px 16px; font-family: system-ui, sans-serif; }
@media (min-width: 640px) { .w2chk-root { padding: 56px 40px; } }
.w2chk-board { position: relative; max-width: 60rem; margin: 0 auto; overflow: hidden; border-radius: 6px; color: var(--w2chk-chalk);
border: 12px solid var(--w2chk-frame); box-shadow: inset 0 0 0 1px rgba(0,0,0,.35), inset 0 0 60px rgba(0,0,0,.45), 0 24px 50px -24px rgba(40,28,16,.6);
background: radial-gradient(40% 30% at 70% 30%, rgba(255,255,255,.06), transparent 70%), radial-gradient(30% 25% at 20% 80%, rgba(255,255,255,.05), transparent 70%), var(--w2chk-slate); }
.w2chk-cv { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; transition: opacity .4s ease; }
.w2chk-root[data-kb] .w2chk-cv { opacity: 0; }
.w2chk-copy { position: relative; padding: 36px 24px 40px; }
@media (min-width: 640px) { .w2chk-copy { padding: 48px 56px 52px; } }
.w2chk-label { margin: 0; font-size: .75rem; letter-spacing: .24em; text-transform: uppercase; color: #cfd8d2; }
.w2chk-copy h2 { margin: 12px 0 0; font-family: "Chalkboard SE", "Segoe Print", Georgia, serif; font-style: italic; font-weight: 400;
font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.1; text-shadow: 0 0 1px rgba(240,237,228,.6); }
.w2chk-menu { margin: 24px 0 0; padding: 0; list-style: none; max-width: 32rem; }
.w2chk-menu li { display: flex; gap: 16px; justify-content: space-between; align-items: baseline; padding: 10px 0; border-bottom: 1px dashed rgba(240,237,228,.3);
font-family: "Chalkboard SE", "Segoe Print", Georgia, serif; font-size: 1.0625rem; }
.w2chk-menu b { font-weight: 400; font-size: 1.25rem; }
.w2chk-btn { margin-top: 28px; display: inline-flex; min-height: 44px; align-items: center; padding: 0 20px; border-radius: 4px; border: 2px solid var(--w2chk-chalk);
color: var(--w2chk-chalk); font-size: .875rem; font-weight: 600; text-decoration: none; }
.w2chk-btn:hover { background: rgba(240,237,228,.1); }
.w2chk-btn:focus-visible { outline: 3px solid #f2c94c; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .w2chk-cv { display: none; } }
</style>
<script>
(function () {
var root = document.querySelector("[data-w2chk]");
if (!root) return;
var DUST = 6; // specks shed per frame of movement
var MAX = 500; // speck pool size
var RGB = "240,237,228"; // chalk colour
if (matchMedia("(prefers-reduced-motion: reduce)").matches) return;
var fine = matchMedia("(hover: hover) and (pointer: fine)").matches;
var board = root.querySelector(".w2chk-board"), cv = root.querySelector(".w2chk-cv"), ctx = cv.getContext("2d");
var dpr = Math.min(devicePixelRatio || 1, 2), W = 0, H = 0, n = 0;
var px = new Float32Array(MAX), py = new Float32Array(MAX), vx = new Float32Array(MAX), vy = new Float32Array(MAX), life = new Float32Array(MAX), sz = new Float32Array(MAX);
var hx = -1, hy = -1, tx = 0, ty = 0, live = false, frame = 0, idle = 0, vis = true, t0 = performance.now();
function size() { W = board.clientWidth; H = board.clientHeight; cv.width = W * dpr; cv.height = H * dpr; ctx.setTransform(dpr, 0, 0, dpr, 0, 0); }
function add(x, y, spread) {
var i = n++ % MAX;
px[i] = x + (Math.random() - .5) * spread; py[i] = y + (Math.random() - .5) * spread;
vx[i] = (Math.random() - .5) * .5; vy[i] = Math.random() * .4; life[i] = 1; sz[i] = .6 + Math.random() * 1.8;
}
function loop(now) {
var alive = 0;
if (fine) {
if (!live) {
var t = (now - t0) / 1000;
tx = W * (0.66 + 0.2 * Math.sin(t * 0.7)) + 28 * Math.cos(t * 4.2); ty = H * (0.5 + 0.26 * Math.sin(t * 1.1)) + 22 * Math.sin(t * 4.2);
}
if (hx < 0) { hx = tx; hy = ty; }
var dx = tx - hx, dy = ty - hy, d = Math.min(1, Math.hypot(dx, dy) / 6);
for (var k = 0; k < DUST * d; k++) { var f = Math.random(); add(hx + dx * f, hy + dy * f, 6); }
hx = tx; hy = ty;
}
ctx.clearRect(0, 0, W, H);
for (var i = 0; i < MAX; i++) {
if (life[i] <= 0) continue;
alive++;
vy[i] += .03; px[i] += vx[i]; py[i] += vy[i]; life[i] -= .01;
ctx.fillStyle = "rgba(" + RGB + "," + (life[i] * .8) + ")";
ctx.fillRect(px[i], py[i], sz[i], sz[i]);
}
frame = vis && (fine || alive) ? requestAnimationFrame(loop) : 0;
}
function start() { if (!frame && vis) frame = requestAnimationFrame(loop); }
function stop() { cancelAnimationFrame(frame); frame = 0; }
size(); new ResizeObserver(size).observe(board);
new IntersectionObserver(function (e) { vis = e[0].isIntersecting; vis && fine ? start() : stop(); }).observe(root);
function at(e) { var r = board.getBoundingClientRect(); tx = e.clientX - r.left; ty = e.clientY - r.top; }
if (!fine) {
// Touch: each tap knocks a small puff of dust off the board.
board.addEventListener("pointerdown", function (e) { at(e); for (var k = 0; k < 40; k++) add(tx, ty, 18); start(); });
return;
}
board.addEventListener("pointermove", function (e) { if (e.pointerType !== "touch") { at(e); live = true; clearTimeout(idle); root.removeAttribute("data-kb"); } });
board.addEventListener("pointerleave", function () { idle = setTimeout(function () { live = false; hx = -1; }, 1500); });
root.addEventListener("focusin", function () { if (root.querySelector(":focus-visible")) root.setAttribute("data-kb", ""); });
root.addEventListener("focusout", function () { root.removeAttribute("data-kb"); });
})();
</script>
With reduced motion: No dust is drawn and the board shows as a still, readable menu.
Running cost: Up to five hundred one-pixel rectangles per frame from a fixed pool; the loop pauses off screen and stops once a tap puff settles.
- Raise `DUST` for heavier chalk or lower it for a faint trace.
- Change `RGB` to tint the dust, such as a pale yellow chalk, and match `--w2chk-chalk`.
- Swap the slate colour `--w2chk-slate` for a deep green board.
Comet Cursor Trail on Canvas
A warm comet with a glowing head and a tapering tail streaks after the pointer across a starry navy sky, behind the listings for a small observatory's public nights. The whole tail is redrawn on a single canvas each frame from a short list of recent positions, so it bends smoothly through curves instead of breaking into separate dots.
<section class="w2cmt-root" data-w2cmt>
<canvas class="w2cmt-cv" aria-hidden="true"></canvas>
<div class="w2cmt-wrap">
<p class="w2cmt-label">Kestrel Hill Observatory</p>
<h2>Public nights on the hill this winter</h2>
<p class="w2cmt-text">Bring warm layers. Our volunteers set up the big refractor on the lawn and walk you through whatever the sky gives us.</p>
<ul class="w2cmt-dates">
<li><span>Fri 7 Nov</span>The Moon and Saturn</li>
<li><span>Sat 13 Dec</span>Watching for meteors</li>
<li><span>Fri 9 Jan</span>The Orion Nebula</li>
</ul>
<a href="#" class="w2cmt-btn">Reserve a telescope slot</a>
</div>
</section>
<style>
/* Change these: --w2cmt-sky (background), --w2cmt-gold (label and button). Tail colour and length are in the script. */
.w2cmt-root { --w2cmt-sky: #0b1630; --w2cmt-gold: #f2cf8a;
position: relative; overflow: hidden; padding: 56px 20px; color: #eef2fb; font-family: system-ui, sans-serif;
background:
radial-gradient(2px 2px at 12% 18%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 33% 72%, #dfe6ff 50%, transparent 51%),
radial-gradient(2.2px 2.2px at 58% 26%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 76% 64%, #cfd9ff 50%, transparent 51%),
radial-gradient(2px 2px at 88% 14%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 46% 88%, #fff 50%, transparent 51%),
radial-gradient(1px 1px at 92% 82%, #dfe6ff 50%, transparent 51%), radial-gradient(2px 2px at 22% 48%, #fff 50%, transparent 51%),
radial-gradient(90% 70% at 80% 0%, #1b2d5c 0%, transparent 70%), var(--w2cmt-sky); }
@media (min-width: 640px) { .w2cmt-root { padding: 72px 48px; } }
.w2cmt-cv { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; transition: opacity .4s ease; }
.w2cmt-root[data-kb] .w2cmt-cv { opacity: 0; }
.w2cmt-wrap { position: relative; max-width: 64rem; margin: 0 auto; }
.w2cmt-label { margin: 0; font-size: .75rem; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: var(--w2cmt-gold); }
.w2cmt-wrap h2 { margin: 14px 0 0; max-width: 34rem; font-family: Georgia, serif; font-weight: 400; font-size: clamp(2rem, 5vw, 3.25rem); line-height: 1.08; }
.w2cmt-text { margin: 16px 0 0; max-width: 30rem; line-height: 1.65; color: #c9d3ea; }
.w2cmt-dates { margin: 28px 0 0; padding: 0; list-style: none; max-width: 26rem; border-top: 1px solid rgba(238,242,251,.18); }
.w2cmt-dates li { display: flex; gap: 16px; padding: 12px 0; border-bottom: 1px solid rgba(238,242,251,.18); font-size: .9375rem; }
.w2cmt-dates span { flex: 0 0 96px; color: var(--w2cmt-gold); font-variant-numeric: tabular-nums; }
.w2cmt-btn { margin-top: 28px; display: inline-flex; min-height: 46px; align-items: center; padding: 0 22px; border-radius: 999px; background: var(--w2cmt-gold);
color: #0b1630; font-size: .875rem; font-weight: 700; text-decoration: none; }
.w2cmt-btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .w2cmt-cv { display: none; } }
</style>
<script>
(function () {
var root = document.querySelector("[data-w2cmt]");
if (!root) return;
var LEN = 40; // points in the tail; longer means a longer comet
var WIDTH = 11; // tail thickness at the head, in px
var RGB = "255,232,190"; // tail colour
if (matchMedia("(prefers-reduced-motion: reduce)").matches || !matchMedia("(hover: hover) and (pointer: fine)").matches) return;
var cv = root.querySelector(".w2cmt-cv"), ctx = cv.getContext("2d");
var dpr = Math.min(devicePixelRatio || 1, 2), W = 0, H = 0, pts = [], hx = 0, hy = 0, tx = 0, ty = 0;
var live = false, frame = 0, idle = 0, t0 = performance.now();
function size() { W = root.clientWidth; H = root.clientHeight; cv.width = W * dpr; cv.height = H * dpr; ctx.setTransform(dpr, 0, 0, dpr, 0, 0); }
function loop(now) {
if (!live) {
var t = (now - t0) / 1000;
tx = W * (0.55 + 0.4 * Math.cos(t * 1.1)); ty = H * (0.5 + 0.34 * Math.sin(t * 1.65));
}
hx += (tx - hx) * 0.22; hy += (ty - hy) * 0.22;
pts.push(hx, hy); if (pts.length > LEN * 2) pts.splice(0, 2);
ctx.clearRect(0, 0, W, H); ctx.lineCap = "round";
var n = pts.length / 2;
for (var i = 1; i < n; i++) {
var k = i / n;
ctx.strokeStyle = "rgba(" + RGB + "," + (k * k * 0.9) + ")"; ctx.lineWidth = WIDTH * k;
ctx.beginPath(); ctx.moveTo(pts[i * 2 - 2], pts[i * 2 - 1]); ctx.lineTo(pts[i * 2], pts[i * 2 + 1]); ctx.stroke();
}
var g = ctx.createRadialGradient(hx, hy, 0, hx, hy, 30);
g.addColorStop(0, "rgba(255,255,255,.95)"); g.addColorStop(0.25, "rgba(" + RGB + ",.5)"); g.addColorStop(1, "rgba(" + RGB + ",0)");
ctx.fillStyle = g; ctx.fillRect(hx - 30, hy - 30, 60, 60);
frame = requestAnimationFrame(loop);
}
function start() { if (!frame) frame = requestAnimationFrame(loop); }
function stop() { cancelAnimationFrame(frame); frame = 0; }
size(); new ResizeObserver(size).observe(root);
new IntersectionObserver(function (e) { e[0].isIntersecting ? start() : stop(); }).observe(root);
root.addEventListener("pointermove", function (e) {
if (e.pointerType === "touch") return;
var r = root.getBoundingClientRect(); tx = e.clientX - r.left; ty = e.clientY - r.top;
live = true; clearTimeout(idle); root.removeAttribute("data-kb");
});
root.addEventListener("pointerleave", function () { idle = setTimeout(function () { live = false; }, 1500); });
root.addEventListener("focusin", function () { if (root.querySelector(":focus-visible")) root.setAttribute("data-kb", ""); });
root.addEventListener("focusout", function () { root.removeAttribute("data-kb"); });
})();
</script>
With reduced motion: No canvas is drawn; the starry background and listings show as a still page.
Running cost: About thirty short line strokes and one small gradient per frame on a canvas capped at 2x pixel ratio, stopped off screen.
- Raise `LEN` for a longer tail or lower it for a quick spark.
- Change `RGB` to recolour the tail, for example a cool `190,220,255` for an icy comet.
- Edit `WIDTH` to make the tail thicker at the head.
Context Cursor With Caret and Ring
One small clay-coloured cursor that changes shape with what lies under it: a dot over empty page, a blinking text caret that settles onto the middle of each line inside a paragraph, and a hand-sized ring around the pointer over buttons. It fits a newsletter, journal or long article page where reading and clicking sit close together.
<section class="w2car-root" data-w2car>
<div class="w2car-wrap">
<p class="w2car-label">Kiln Notes, from Ashgrove Pottery</p>
<h2>What the last firing taught us about ash glaze</h2>
<p class="w2car-p" data-c="text">We packed the back of the kiln tighter than usual and the ash settled thickest on the shoulders of the tall jars. Where it pooled, the glaze ran green and glassy; where it thinned, the clay came through warm and orange.</p>
<p class="w2car-p" data-c="text">Next time we will leave a hand's width between the rows and load the wide bowls lower down, where the flame moves slowest.</p>
<div class="w2car-ctas">
<button type="button" class="w2car-btn" data-c="btn">Get the next letter</button>
<a href="#" class="w2car-btn w2car-ghost" data-c="btn">Read past issues</a>
</div>
</div>
<span class="w2car-cur" aria-hidden="true">
<span class="w2car-dot"></span><span class="w2car-bar"></span><span class="w2car-ring"></span>
</span>
</section>
<style>
/* Change these: --w2car-clay (cursor and accent), --w2car-paper (background), --w2car-ring (ring diameter over buttons). */
.w2car-root { --w2car-clay: #b4532a; --w2car-paper: #f4e9df; --w2car-ring: 58px;
position: relative; overflow: hidden; padding: 56px 20px; background: var(--w2car-paper); color: #2e1c14; font-family: system-ui, sans-serif; }
@media (min-width: 640px) { .w2car-root { padding: 72px 40px; } }
.w2car-wrap { max-width: 42rem; margin: 0 auto; }
.w2car-label { margin: 0; font-size: .75rem; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: #93401d; }
.w2car-wrap h2 { margin: 14px 0 0; font-family: Georgia, serif; font-weight: 400; font-size: clamp(1.9rem, 4.4vw, 2.8rem); line-height: 1.12; }
.w2car-p { margin: 20px 0 0; font-family: Georgia, serif; font-size: 1.125rem; line-height: 1.7; color: #4a3226; }
.w2car-ctas { margin-top: 32px; display: flex; flex-wrap: wrap; gap: 12px; }
.w2car-btn { display: inline-flex; min-height: 48px; align-items: center; padding: 0 24px; border: 0; border-radius: 999px; background: var(--w2car-clay); color: #fff8f2;
font: 600 .9375rem system-ui, sans-serif; text-decoration: none; cursor: pointer; }
.w2car-ghost { background: transparent; color: #2e1c14; box-shadow: inset 0 0 0 1.5px rgba(46,28,20,.35); }
.w2car-btn:focus-visible { outline: 3px solid #2e1c14; outline-offset: 3px; }
.w2car-cur { position: absolute; left: 0; top: 0; pointer-events: none; opacity: 0; transition: opacity .3s ease; will-change: transform; }
.w2car-cur > span { position: absolute; left: 0; top: 0; transition: opacity .2s ease, transform .35s cubic-bezier(.2,.9,.3,1.2); }
.w2car-dot { width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--w2car-clay); }
.w2car-bar { width: 2px; height: 28px; margin: -14px 0 0 -1px; background: var(--w2car-clay); opacity: 0; transform: scaleY(.3); }
.w2car-ring { width: var(--w2car-ring); height: var(--w2car-ring); margin: calc(var(--w2car-ring) / -2) 0 0 calc(var(--w2car-ring) / -2); border-radius: 50%;
border: 2px solid #2e1c14; background: rgba(255,248,242,.18); opacity: 0; transform: scale(.2); }
.w2car-root[data-on] .w2car-cur { opacity: 1; }
.w2car-root[data-kb] .w2car-cur { opacity: 0; }
.w2car-root[data-mode="text"] .w2car-dot, .w2car-root[data-mode="btn"] .w2car-dot { opacity: 0; transform: scale(.2); }
.w2car-root[data-mode="text"] .w2car-bar { opacity: 1; transform: none; animation: w2car-blink 1.1s steps(1) .5s infinite; }
.w2car-root[data-mode="btn"] .w2car-ring { opacity: 1; transform: none; }
@keyframes w2car-blink { 50% { opacity: .15; } }
.w2car-root[data-paused] .w2car-bar { animation-play-state: paused; }
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
.w2car-root[data-live], .w2car-root[data-live] * { cursor: none; }
}
@media (prefers-reduced-motion: reduce) { .w2car-cur { display: none; } }
</style>
<script>
(function () {
var root = document.querySelector("[data-w2car]");
if (!root) return;
var EASE = 0.3; // how quickly the cursor follows (0 to 1)
var IDLE_MS = 1700; // how long the demo rests on each target
if (matchMedia("(prefers-reduced-motion: reduce)").matches || !matchMedia("(hover: hover) and (pointer: fine)").matches) return;
var cur = root.querySelector(".w2car-cur"), spots = root.querySelectorAll("[data-c]");
root.setAttribute("data-on", "");
var x = 0, y = 0, tx = 0, ty = 0, hot = null, live = false, mode = "", frame = 0, idle = 0, t0 = performance.now();
function setMode(m) { if (m !== mode) { mode = m; m ? root.setAttribute("data-mode", m) : root.removeAttribute("data-mode"); } }
// In text, the caret sits on the middle of the line under the pointer.
function onLine(el, yy, o) {
var r = el.getBoundingClientRect(), lh = parseFloat(getComputedStyle(el).lineHeight), top = r.top - o.top;
return top + (Math.floor((yy - top) / lh) + 0.5) * lh;
}
function loop(now) {
var o = root.getBoundingClientRect(), target = hot;
if (!live) {
var t = Math.max(0, now - t0) / IDLE_MS, el = spots[[0, 2, 1, 3][Math.floor(t) % 4]], r = el.getBoundingClientRect(), f = t % 1;
target = el;
tx = r.left - o.left + r.width * (el.dataset.c === "text" ? 0.15 + 0.6 * f : 0.5); ty = r.top - o.top + r.height * (el.dataset.c === "text" ? 0.4 : 0.5);
}
var m = target ? target.dataset.c : "";
setMode(m);
var yy = m === "text" ? onLine(target, ty, o) : ty;
x += (tx - x) * EASE; y += (yy - y) * EASE;
cur.style.transform = "translate(" + x + "px," + y + "px)";
frame = requestAnimationFrame(loop);
}
function start() { if (!frame) { frame = requestAnimationFrame(loop); root.removeAttribute("data-paused"); } }
function stop() { cancelAnimationFrame(frame); frame = 0; root.setAttribute("data-paused", ""); }
new IntersectionObserver(function (e) { e[0].isIntersecting ? start() : stop(); }).observe(root);
root.addEventListener("pointermove", function (e) {
if (e.pointerType === "touch") return;
var o = root.getBoundingClientRect(); tx = e.clientX - o.left; ty = e.clientY - o.top;
hot = e.target.closest("[data-c]"); live = true; clearTimeout(idle);
root.setAttribute("data-live", ""); root.removeAttribute("data-kb");
});
root.addEventListener("pointerleave", function () { hot = null; root.removeAttribute("data-live"); idle = setTimeout(function () { live = false; }, 1500); });
// Keyboard focus: the cursor steps aside so the dark focus outline stays in view.
root.addEventListener("focusin", function () { if (root.querySelector(":focus-visible")) root.setAttribute("data-kb", ""); });
root.addEventListener("focusout", function () { root.removeAttribute("data-kb"); });
})();
</script>
With reduced motion: The custom cursor never appears and the regular arrow, text and hand cursors work as usual.
Running cost: One element moved with transform plus a short opacity blink; the loop and blink pause off screen.
- Tag any element with `data-c="text"` or `data-c="btn"` to choose which shape appears over it.
- Change `--w2car-ring` (58px in React) to size the button ring and `--w2car-clay` to recolour the dot and caret.
- Remove the `w2car-blink` animation line if you prefer a caret that stays solid.
Difference Blend Dot Cursor
A white disc set to mix-blend-mode difference rides along with the pointer over a type specimen, flipping black letters to cream and the bone paper to near black wherever it passes. It stays a small bead over empty space and swells to full size across the giant headline and links. Good for a type foundry, poster studio or any page built around one huge word.
<section class="w2dif-root" data-w2dif>
<div class="w2dif-wrap">
<div class="w2dif-top">
<p class="w2dif-label">Orrery Type, specimen sheet</p>
<a href="#" class="w2dif-link" data-grow>Download trial fonts</a>
</div>
<h2 class="w2dif-big" data-grow><span>Hollis</span> <span>Grotesk</span> <span>Heavy</span></h2>
<div class="w2dif-foot">
<p>A wide, low-contrast sans drawn for signage, posters and anything read from across a room.</p>
<a href="#" class="w2dif-btn" data-grow>License the family</a>
</div>
</div>
<span class="w2dif-dot" aria-hidden="true"></span>
</section>
<style>
/* Change these: --w2dif-paper and --w2dif-ink (the two colours that invert), --w2dif-size (full dot size), --w2dif-rest (dot scale away from type). */
.w2dif-root { --w2dif-paper: #ece6da; --w2dif-ink: #121212; --w2dif-size: 132px; --w2dif-rest: .3;
position: relative; overflow: hidden; isolation: isolate; padding: 48px 20px; background: var(--w2dif-paper); color: var(--w2dif-ink); font-family: system-ui, sans-serif; }
@media (min-width: 640px) { .w2dif-root { padding: 56px 48px; } }
.w2dif-wrap { max-width: 72rem; margin: 0 auto; }
.w2dif-top, .w2dif-foot { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; }
.w2dif-label { margin: 0; font-size: .75rem; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; }
.w2dif-link { display: inline-flex; min-height: 40px; align-items: center; color: inherit; font-size: .875rem; font-weight: 600; text-underline-offset: 4px; }
.w2dif-big { margin: 32px 0; font-size: clamp(3rem, 14vw, 11.5rem); font-weight: 900; line-height: .86; letter-spacing: -.05em; text-transform: uppercase; }
.w2dif-big span { display: block; }
@media (min-width: 640px) { .w2dif-big span:nth-child(2) { padding-left: .5em; } }
.w2dif-foot p { margin: 0; max-width: 26rem; font-size: 1rem; line-height: 1.6; }
.w2dif-btn { display: inline-flex; min-height: 48px; align-items: center; padding: 0 26px; border-radius: 999px; background: var(--w2dif-ink); color: var(--w2dif-paper);
font-size: .9375rem; font-weight: 700; text-decoration: none; }
.w2dif-root a:focus-visible { outline: 3px solid #c2410c; outline-offset: 4px; }
.w2dif-dot { position: absolute; left: 0; top: 0; width: var(--w2dif-size); height: var(--w2dif-size); margin: calc(var(--w2dif-size) / -2) 0 0 calc(var(--w2dif-size) / -2);
border-radius: 50%; background: #fff; mix-blend-mode: difference; pointer-events: none; opacity: 0; transition: opacity .3s ease; will-change: transform; }
.w2dif-root[data-on] .w2dif-dot { opacity: 1; }
.w2dif-root[data-kb] .w2dif-dot { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .w2dif-dot { display: none; } }
</style>
<script>
(function () {
var root = document.querySelector("[data-w2dif]");
if (!root) return;
var EASE = 0.2; // how quickly the dot follows (0 to 1)
var REST = 0.3; // dot scale away from type, same as --w2dif-rest
if (matchMedia("(prefers-reduced-motion: reduce)").matches || !matchMedia("(hover: hover) and (pointer: fine)").matches) return;
var dot = root.querySelector(".w2dif-dot"), big = root.querySelector(".w2dif-big");
root.setAttribute("data-on", "");
var x = -200, y = -200, s = REST, tx = 0, ty = 0, ts = REST, live = false, frame = 0, idle = 0, t0 = performance.now();
function loop(now) {
if (!live) {
// Idle demo: drift over the big word, swelling as it crosses the letters.
var t = (now - t0) / 1000, o = root.getBoundingClientRect(), b = big.getBoundingClientRect();
tx = b.left - o.left + b.width * (0.3 + 0.24 * Math.sin(t * 0.6));
ty = b.top - o.top + b.height * (0.5 + 0.45 * Math.sin(t * 1.3));
ts = 1;
}
x += (tx - x) * EASE; y += (ty - y) * EASE; s += (ts - s) * 0.14;
dot.style.transform = "translate(" + x + "px," + y + "px) scale(" + s + ")";
frame = requestAnimationFrame(loop);
}
function start() { if (!frame) frame = requestAnimationFrame(loop); }
function stop() { cancelAnimationFrame(frame); frame = 0; }
new IntersectionObserver(function (e) { e[0].isIntersecting ? start() : stop(); }).observe(root);
root.addEventListener("pointermove", function (e) {
if (e.pointerType === "touch") return;
var o = root.getBoundingClientRect();
tx = e.clientX - o.left; ty = e.clientY - o.top;
ts = e.target.closest("[data-grow]") ? 1 : REST;
live = true; clearTimeout(idle); root.removeAttribute("data-kb");
});
root.addEventListener("pointerleave", function () { ts = REST; idle = setTimeout(function () { live = false; }, 1500); });
// Keyboard focus: the dot steps aside so the focus outline keeps its true colour.
root.addEventListener("focusin", function () { if (root.querySelector(":focus-visible")) root.setAttribute("data-kb", ""); });
root.addEventListener("focusout", function () { root.removeAttribute("data-kb"); });
})();
</script>
With reduced motion: The disc never appears and the specimen reads as plain black type on paper.
Running cost: One element moved with transform; the blend is done by the compositor, though a very large disc does cost a little more to blend.
- Set `--w2dif-size` (or `SIZE` in React) for the full disc, and `REST` for how small it shrinks between words.
- Swap `--w2dif-paper` and `--w2dif-ink`; the inverted colours follow automatically because difference subtracts the disc from whatever lies beneath.
- Add `data-grow` to any other element that should make the disc swell.
Eased Ring Cursor That Snaps to Links
A thin ring trails a small dot that marks the exact click point. Over a link the ring stops following freely, slides onto the link's arrow button or label, grows to frame it and fills with a faint wash, while still leaning slightly toward the pointer. It suits an architecture or design studio index where each row is a big, deliberate click.
<section class="w2rng-root" data-w2rng>
<div class="w2rng-wrap">
<nav class="w2rng-nav" aria-label="Halden Works">
<a href="#" class="w2rng-brand" data-snap>Halden Works</a>
<ul>
<li><a href="#" data-snap>Studio</a></li>
<li><a href="#" data-snap>Journal</a></li>
<li><a href="#" data-snap>Contact</a></li>
</ul>
</nav>
<h2 class="w2rng-title">Selected buildings</h2>
<ul class="w2rng-list">
<li><a href="#" data-snap><span class="w2rng-name">Kettle Yard Library</span><span class="w2rng-meta">Ashby, 2025</span><span class="w2rng-arrow" aria-hidden="true">→</span></a></li>
<li><a href="#" data-snap><span class="w2rng-name">Salt Store Housing</span><span class="w2rng-meta">Felixmouth, 2024</span><span class="w2rng-arrow" aria-hidden="true">→</span></a></li>
<li><a href="#" data-snap><span class="w2rng-name">Orchard Lane School</span><span class="w2rng-meta">Brimley, 2023</span><span class="w2rng-arrow" aria-hidden="true">→</span></a></li>
<li><a href="#" data-snap><span class="w2rng-name">Tidemill Studios</span><span class="w2rng-meta">Harwick, 2022</span><span class="w2rng-arrow" aria-hidden="true">→</span></a></li>
</ul>
</div>
<span class="w2rng-ring" aria-hidden="true"><span class="w2rng-fill"></span></span>
<span class="w2rng-dot" aria-hidden="true"></span>
</section>
<style>
/* Change these: --w2rng-ink (text and ring), --w2rng-paper (background), --w2rng-size (ring diameter; keep SIZE in the script equal). */
.w2rng-root { --w2rng-ink: #1e293b; --w2rng-paper: #f6f7f9; --w2rng-size: 40px;
position: relative; overflow: hidden; padding: 48px 20px 64px; background: var(--w2rng-paper); color: var(--w2rng-ink); font-family: system-ui, sans-serif; }
@media (min-width: 640px) { .w2rng-root { padding: 56px 40px 72px; } }
.w2rng-wrap { max-width: 64rem; margin: 0 auto; }
.w2rng-nav { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.w2rng-nav ul { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; }
.w2rng-nav a { display: inline-flex; min-height: 40px; align-items: center; padding: 0 12px; border-radius: 999px; color: #475569; font-size: .875rem; text-decoration: none; }
.w2rng-nav .w2rng-brand { padding: 0; color: var(--w2rng-ink); font-weight: 700; letter-spacing: -.01em; font-size: 1rem; }
.w2rng-title { margin: 48px 0 16px; font-size: .75rem; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: #475569; }
.w2rng-list { margin: 0; padding: 0; list-style: none; border-bottom: 1px solid #d5dae1; }
.w2rng-list a { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 16px; padding: 20px 0; border-top: 1px solid #d5dae1;
color: inherit; text-decoration: none; }
.w2rng-name { font-size: clamp(1.4rem, 3.6vw, 2.4rem); font-weight: 600; letter-spacing: -.02em; line-height: 1.15; transition: transform .4s cubic-bezier(.2,.8,.2,1); }
.w2rng-meta { grid-column: 1; font-size: .875rem; color: #475569; }
.w2rng-arrow { grid-column: 2; grid-row: 1 / span 2; width: 48px; height: 48px; border-radius: 50%; border: 1px solid #c5ccd6;
display: grid; place-items: center; font-size: 1.1rem; background: #fff; }
@media (min-width: 768px) { .w2rng-list a { grid-template-columns: 1fr 200px auto; } .w2rng-meta { grid-column: 2; grid-row: 1; } .w2rng-arrow { grid-column: 3; grid-row: 1; } }
.w2rng-list a:hover .w2rng-name, .w2rng-list a:focus-visible .w2rng-name { transform: translateX(8px); }
.w2rng-root a:focus-visible { outline: 2px solid #2563eb; outline-offset: 4px; }
.w2rng-ring, .w2rng-dot { position: absolute; left: 0; top: 0; pointer-events: none; opacity: 0; transition: opacity .3s ease; will-change: transform; }
.w2rng-ring { width: var(--w2rng-size); height: var(--w2rng-size); margin: calc(var(--w2rng-size) / -2) 0 0 calc(var(--w2rng-size) / -2);
border-radius: 50%; border: 1px solid var(--w2rng-ink); }
.w2rng-fill { position: absolute; inset: 0; border-radius: 50%; background: rgba(30,41,59,.08); opacity: 0; transition: opacity .3s ease; }
.w2rng-root[data-hot] .w2rng-fill { opacity: 1; }
.w2rng-dot { width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: var(--w2rng-ink); }
.w2rng-root[data-on] .w2rng-ring, .w2rng-root[data-on] .w2rng-dot { opacity: 1; }
.w2rng-root[data-kb] .w2rng-ring, .w2rng-root[data-kb] .w2rng-dot { opacity: 0; }
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
.w2rng-root[data-on][data-live], .w2rng-root[data-on][data-live] * { cursor: none; }
}
@media (prefers-reduced-motion: reduce) { .w2rng-ring, .w2rng-dot { display: none; } .w2rng-name { transition: none; } }
</style>
<script>
(function () {
var root = document.querySelector("[data-w2rng]");
if (!root) return;
var EASE = 0.16; // how quickly the ring catches up (0 to 1)
var SIZE = 40; // ring diameter in px, same as --w2rng-size
var PULL = 0.18; // how far a snapped ring still leans toward the pointer
if (matchMedia("(prefers-reduced-motion: reduce)").matches || !matchMedia("(hover: hover) and (pointer: fine)").matches) return;
var ring = root.querySelector(".w2rng-ring"), dot = root.querySelector(".w2rng-dot");
var snaps = root.querySelectorAll("[data-snap]");
root.setAttribute("data-on", "");
var px = 0, py = 0, rx = 0, ry = 0, rs = 1, hot = null, live = false, was = null, frame = 0, idle = 0, t0 = performance.now();
function box(el) {
var a = (el.querySelector(".w2rng-arrow") || el).getBoundingClientRect(), o = root.getBoundingClientRect();
return { x: a.left - o.left + a.width / 2, y: a.top - o.top + a.height / 2, s: Math.min(Math.max(a.width, a.height) + 14, 84) / SIZE };
}
function loop(now) {
var target = live ? hot : snaps[Math.floor(Math.max(0, now - t0) / 1700) % snaps.length], tx = px, ty = py, ts = 1;
if (target) {
var b = box(target);
if (!live) { px += (b.x - px) * 0.1; py += (b.y - py) * 0.1; }
tx = b.x + (px - b.x) * PULL; ty = b.y + (py - b.y) * PULL; ts = b.s;
}
rx += (tx - rx) * EASE; ry += (ty - ry) * EASE; rs += (ts - rs) * EASE;
ring.style.transform = "translate(" + rx + "px," + ry + "px) scale(" + rs + ")";
dot.style.transform = "translate(" + px + "px," + py + "px)";
if (!!target !== was) { was = !!target; was ? root.setAttribute("data-hot", "") : root.removeAttribute("data-hot"); }
frame = requestAnimationFrame(loop);
}
function start() { if (!frame) frame = requestAnimationFrame(loop); }
function stop() { cancelAnimationFrame(frame); frame = 0; }
new IntersectionObserver(function (e) { e[0].isIntersecting ? start() : stop(); }).observe(root);
root.addEventListener("pointermove", function (e) {
if (e.pointerType === "touch") return;
var o = root.getBoundingClientRect();
px = e.clientX - o.left; py = e.clientY - o.top;
hot = e.target.closest("[data-snap]");
live = true; clearTimeout(idle);
root.setAttribute("data-live", ""); root.removeAttribute("data-kb");
});
root.addEventListener("pointerleave", function () {
hot = null; root.removeAttribute("data-live");
idle = setTimeout(function () { live = false; }, 1500);
});
// Keyboard focus: the ring steps aside and the page's own focus outline does the work.
root.addEventListener("focusin", function () { if (root.querySelector(":focus-visible")) root.setAttribute("data-kb", ""); });
root.addEventListener("focusout", function () { root.removeAttribute("data-kb"); });
})();
</script>
With reduced motion: The ring and dot never appear and the normal system cursor stays.
Running cost: Two elements moved with transform in one frame loop, plus one rectangle read per frame while snapped; paused off screen.
- Lower `EASE` toward 0.1 for a slower, floatier ring, or raise it toward 0.3 for a snappy one.
- Set `PULL` to 0 for a ring that locks dead centre on a link, or 0.35 for one that strains toward the pointer.
- Change `--w2rng-ink` and the `.w2rng-fill` wash colour to recolour the ring for a dark page.
Grid Tiles Light Up Under the Pointer
A lighting designer's hero drawn on a faint graphite grid. Tiles near the pointer warm up like a lamp switched on, brightest in the middle and softer at the edge, then cool down slowly once it moves away, which leaves a short glowing wake. Only each tile's opacity changes. A slow drift lights the grid before anyone arrives, and tabbing to a button lights the tiles around it.
<section class="w7til" data-w7til aria-label="Fieldlight Studio lighting design">
<div class="w7til-grid" aria-hidden="true"></div>
<div class="w7til-body">
<p class="w7til-eye">Fieldlight Studio</p>
<h2 class="w7til-h">Lighting for rooms that are lived in after dark</h2>
<p class="w7til-p">We plan light the way a cabinetmaker plans joints: a lamp where you read, a low wash where you cook, and nothing glaring at the sofa.</p>
<div class="w7til-row">
<a class="w7til-btn" href="#">Book a night visit</a>
<a class="w7til-ghost" href="#">See finished rooms</a>
</div>
</div>
</section>
<style>
/* Change these: --w7til-size (tile size), --w7til-glow (light colour), --w7til-bg, --w7til-ink. Reach and brightness are in the script. */
.w7til { --w7til-size: 56px; --w7til-glow: #f2d39d; --w7til-bg: #141518; --w7til-ink: #f1ede4;
position: relative; height: 560px; overflow: hidden; background: var(--w7til-bg); color: var(--w7til-ink); touch-action: pan-y;
font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; display: flex; align-items: center; justify-content: center; }
.w7til-grid { position: absolute; inset: 0; pointer-events: none;
background-image: linear-gradient(rgba(241,237,228,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(241,237,228,.06) 1px, transparent 1px);
background-size: var(--w7til-size) var(--w7til-size); }
.w7til-grid i { position: absolute; left: 0; top: 0; width: calc(var(--w7til-size) - 1px); height: calc(var(--w7til-size) - 1px); margin: 1px 0 0 1px; background: var(--w7til-glow); opacity: 0; }
.w7til-body { position: relative; max-width: 42rem; padding: 32px 20px; text-align: center; }
.w7til-eye { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .22em; text-transform: uppercase; color: var(--w7til-glow); }
.w7til-h { margin: 14px 0 0; font-size: clamp(2.2rem, 5.8vw, 4rem); font-weight: 600; line-height: 1.04; letter-spacing: -.03em; text-shadow: 0 2px 24px rgba(20,21,24,.9); }
.w7til-p { margin: 18px auto 0; max-width: 30rem; font-size: 16px; line-height: 1.65; color: #cfc9bd; text-shadow: 0 1px 12px rgba(20,21,24,.95); }
.w7til-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 30px; }
.w7til-btn, .w7til-ghost { display: inline-flex; align-items: center; min-height: 48px; padding: 0 24px; border-radius: 999px; font-weight: 600; font-size: 15px; text-decoration: none; }
.w7til-btn { background: var(--w7til-glow); color: #1d1608; }
.w7til-btn:hover { background: #f8e2bb; }
.w7til-ghost { background: rgba(20,21,24,.7); color: var(--w7til-ink); border: 1px solid rgba(241,237,228,.3); }
.w7til-ghost:hover { border-color: var(--w7til-ink); }
.w7til-btn:focus-visible, .w7til-ghost:focus-visible { outline: 3px solid var(--w7til-ink); outline-offset: 3px; }
</style>
<script>
(function () {
var root = document.querySelector("[data-w7til]");
if (!root) return;
var off = [];
//BODY-START
var REACH = 150, MAX = .42, FADE = .05, IDLE_AFTER = 1800; // px radius of light, brightest tile, fade-out speed per frame, ms before the demo resumes
var reduce = matchMedia("(prefers-reduced-motion: reduce)").matches;
var grid = root.querySelector(".w7til-grid"), tiles = [], cx = [], cy = [], cur = [];
var tx = -999, ty = -999, real = 0, raf = 0, seen = true;
function build() {
grid.textContent = ""; tiles = []; cx = []; cy = []; cur = [];
var S = parseFloat(getComputedStyle(root).getPropertyValue("--w7til-size")) || 56;
for (var y = 0; y < root.clientHeight; y += S) for (var x = 0; x < root.clientWidth; x += S) {
var t = document.createElement("i");
t.style.transform = "translate(" + x + "px," + y + "px)";
grid.appendChild(t); tiles.push(t); cx.push(x + S / 2); cy.push(y + S / 2); cur.push(0);
}
}
function light(px, py, ease) {
for (var i = 0; i < tiles.length; i++) {
var d = Math.hypot(cx[i] - px, cy[i] - py), g = d < REACH ? Math.pow(1 - d / REACH, 2) * MAX : 0;
var n = ease ? cur[i] + (g - cur[i]) * (g > cur[i] ? .3 : FADE) : g;
if (Math.abs(n - cur[i]) > .003 || !ease) { cur[i] = n; tiles[i].style.opacity = n.toFixed(3); }
}
}
build();
off.push(function () { grid.textContent = ""; });
if (reduce) { light(root.clientWidth * .78, root.clientHeight * .3, false); return; }
function path(t) { return [root.clientWidth * (.5 + .4 * Math.sin(t * .0006)), root.clientHeight * (.5 + .34 * Math.cos(t * .0011))]; }
function tick(t) {
raf = requestAnimationFrame(tick);
if (!real || t - real > IDLE_AFTER) { var q = path(t); tx = q[0]; ty = q[1]; }
light(tx, ty, true);
}
for (var j = 40; j > 0; j--) { var q = path(performance.now() - j * 17); light(q[0], q[1], true); }
function aim(x, y, hold) { var b = root.getBoundingClientRect(); tx = x - b.left; ty = y - b.top; real = performance.now() + (hold || 0); }
function move(e) { aim(e.clientX, e.clientY); }
function focus(e) { var r = e.target.getBoundingClientRect(); aim(r.left + r.width / 2, r.top + r.height / 2, 4000); }
function leave() { real = 0; }
root.addEventListener("pointermove", move);
root.addEventListener("pointerdown", move);
root.addEventListener("pointerleave", leave);
root.addEventListener("focusin", focus);
var once = true, ro = new ResizeObserver(function () { if (once) once = false; else build(); });
ro.observe(root);
off.push(function () { root.removeEventListener("pointermove", move); root.removeEventListener("pointerdown", move); root.removeEventListener("pointerleave", leave); root.removeEventListener("focusin", focus); ro.disconnect(); });
function play() { if (!raf && seen) raf = requestAnimationFrame(tick); }
function stop() { cancelAnimationFrame(raf); raf = 0; }
var io = new IntersectionObserver(function (e) { seen = e[0].isIntersecting; if (seen) play(); else stop(); });
io.observe(root);
off.push(stop, function () { io.disconnect(); });
play();
//BODY-END
})();
</script>
With reduced motion: A single still patch of warm tiles glows near the top right corner.
Running cost: A few hundred tiles on a wide screen, but only those whose glow changed get an opacity write each frame; the loop pauses off screen.
- Change the tile size with `--w7til-size` and the warm colour with `--w7til-glow`.
- Widen the pool of light with `REACH`, brighten it with `MAX`, and lengthen the wake by lowering `FADE`.
Label Cursor for View, Drag and Play
A dark disc grows under the pointer whenever it enters a card and spells out what a click will do there: View on a project photo, Drag on a sideways plant palette, Play on a film still. Each card also carries a small printed chip with the same words, so nothing depends on hovering. The palette really does drag with a mouse and scrolls with a finger or the arrow keys.
<section class="w2lbl-root" data-w2lbl>
<div class="w2lbl-wrap">
<div class="w2lbl-head">
<h2>Recent gardens</h2>
<p>Ferncombe & Lowe design planted gardens for farmhouses, schools and small town yards.</p>
</div>
<div class="w2lbl-grid">
<a href="#" class="w2lbl-card" data-label="View">
<img src="https://images.pexels.com/photos/38162588/pexels-photo-38162588.jpeg?auto=compress&cs=tinysrgb&w=800" alt="Pale violet bearded irises flowering along a weathered wooden picket fence" loading="lazy" width="800" height="1200">
<span class="w2lbl-cap"><span class="w2lbl-t">Iris walk, Holloway Farm</span><span class="w2lbl-chip">View project</span></span>
</a>
<div class="w2lbl-card w2lbl-palette" data-label="Drag">
<div class="w2lbl-strip" tabindex="0" role="region" aria-label="Plant palette, scrolls sideways">
<div class="w2lbl-sw" style="--c:#6d5a9c"><b>Bearded iris</b><i>Violet, May</i></div>
<div class="w2lbl-sw" style="--c:#b7c35a"><b>Lady's mantle</b><i>Lime froth, June</i></div>
<div class="w2lbl-sw" style="--c:#8e93c4"><b>Catmint</b><i>Soft blue, all summer</i></div>
<div class="w2lbl-sw" style="--c:#c9a43a"><b>Hakone grass</b><i>Gold, autumn</i></div>
<div class="w2lbl-sw" style="--c:#a4553a"><b>Sedum</b><i>Rust heads, October</i></div>
</div>
<span class="w2lbl-cap"><span class="w2lbl-t">The spring plant palette</span><span class="w2lbl-chip">Drag to browse</span></span>
</div>
<div class="w2lbl-card w2lbl-film" data-label="Play">
<img src="https://images.pexels.com/photos/30371404/pexels-photo-30371404.jpeg?auto=compress&cs=tinysrgb&w=800" alt="A gardener's hands setting young seedlings into dark, freshly turned soil" loading="lazy" width="800" height="533">
<button type="button" class="w2lbl-play" aria-pressed="false" aria-label="Play the film: planting a spring border"><svg viewBox="0 0 24 24" width="22" height="22" aria-hidden="true"><path d="M8 5v14l11-7z" fill="currentColor"/></svg></button>
<span class="w2lbl-cap"><span class="w2lbl-t">Planting a spring border</span><span class="w2lbl-chip">Play film</span></span>
</div>
</div>
</div>
<span class="w2lbl-cur" aria-hidden="true"><span class="w2lbl-txt">View</span></span>
</section>
<style>
/* Change these: --w2lbl-ink (cursor and text), --w2lbl-paper (background), --w2lbl-size (cursor diameter). Labels come from each card's data-label. */
.w2lbl-root { --w2lbl-ink: #1d2b22; --w2lbl-paper: #eef1ea; --w2lbl-size: 92px;
position: relative; overflow: hidden; padding: 48px 20px 56px; background: var(--w2lbl-paper); color: var(--w2lbl-ink); font-family: system-ui, sans-serif; }
@media (min-width: 640px) { .w2lbl-root { padding: 64px 40px; } }
.w2lbl-wrap { max-width: 72rem; margin: 0 auto; }
.w2lbl-head { display: flex; flex-wrap: wrap; gap: 8px 32px; align-items: end; justify-content: space-between; }
.w2lbl-head h2 { margin: 0; font-family: Georgia, serif; font-weight: 400; font-size: clamp(1.9rem, 4vw, 2.75rem); }
.w2lbl-head p { margin: 0; max-width: 24rem; font-size: .9375rem; line-height: 1.6; color: #3f4d43; }
.w2lbl-grid { margin-top: 32px; display: grid; gap: 16px; }
@media (min-width: 768px) { .w2lbl-grid { grid-template-columns: repeat(3, 1fr); gap: 20px; } }
.w2lbl-card { position: relative; display: block; overflow: hidden; border-radius: 14px; aspect-ratio: 4 / 5; background: #dfe5da; color: inherit; text-decoration: none;
box-shadow: 0 1px 2px rgba(29,43,34,.08), 0 18px 40px -24px rgba(29,43,34,.45); }
@media (max-width: 767px) { .w2lbl-card { aspect-ratio: 4 / 3; } }
.w2lbl-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .7s cubic-bezier(.2,.8,.2,1); }
.w2lbl-card:hover img, .w2lbl-card:focus-visible img { transform: scale(1.04); }
.w2lbl-film img { filter: brightness(.72); }
.w2lbl-cap { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
padding: 10px 12px; border-radius: 10px; background: rgba(247,248,244,.94); }
.w2lbl-t { font-size: .9375rem; font-weight: 600; }
.w2lbl-chip { font-size: .75rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--w2lbl-ink); color: #f1efe6; }
.w2lbl-palette { background: #e4e8de; }
.w2lbl-strip { position: absolute; inset: 0 0 72px; display: flex; gap: 12px; padding: 16px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; user-select: none; }
.w2lbl-sw { flex: 0 0 62%; scroll-snap-align: start; border-radius: 10px; background: #f7f8f4; display: flex; flex-direction: column; justify-content: flex-end; padding: 12px; gap: 2px;
background-image: linear-gradient(var(--c), var(--c)); background-size: 100% 64%; background-repeat: no-repeat; }
.w2lbl-sw b { font-size: .9375rem; }
.w2lbl-sw i { font-style: normal; font-size: .8125rem; color: #3f4d43; }
.w2lbl-play { position: absolute; left: 50%; top: 42%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border: 0; border-radius: 50%;
background: rgba(247,248,244,.92); color: var(--w2lbl-ink); display: grid; place-items: center; cursor: pointer; }
.w2lbl-play[aria-pressed="true"] { background: var(--w2lbl-ink); color: #f1efe6; }
.w2lbl-root a:focus-visible, .w2lbl-root button:focus-visible, .w2lbl-strip:focus-visible { outline: 3px solid #b45309; outline-offset: 3px; }
.w2lbl-cur { position: absolute; left: 0; top: 0; width: var(--w2lbl-size); height: var(--w2lbl-size); margin: calc(var(--w2lbl-size) / -2) 0 0 calc(var(--w2lbl-size) / -2);
border-radius: 50%; background: var(--w2lbl-ink); color: #f1efe6; display: grid; place-items: center; pointer-events: none; will-change: transform;
box-shadow: 0 10px 30px -12px rgba(29,43,34,.6); transform: scale(0); }
.w2lbl-txt { font-size: .75rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.w2lbl-root[data-kb] .w2lbl-cur { opacity: 0; }
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
.w2lbl-root[data-live] [data-label], .w2lbl-root[data-live] [data-label] * { cursor: none; }
}
@media (prefers-reduced-motion: reduce) { .w2lbl-cur { display: none; } .w2lbl-card img { transition: none; } }
</style>
<script>
(function () {
var root = document.querySelector("[data-w2lbl]");
if (!root) return;
var EASE = 0.2; // how quickly the label catches the pointer
var IDLE_MS = 1800; // time the demo spends on each card
var strip = root.querySelector(".w2lbl-strip"), play = root.querySelector(".w2lbl-play");
play.addEventListener("click", function () { play.setAttribute("aria-pressed", play.getAttribute("aria-pressed") === "true" ? "false" : "true"); });
// Mouse drag on the plant palette (touch and keys scroll it natively).
var dragX = null, from = 0;
strip.addEventListener("pointerdown", function (e) { if (e.pointerType === "mouse") { dragX = e.clientX; from = strip.scrollLeft; strip.setPointerCapture(e.pointerId); strip.style.scrollSnapType = "none"; } });
strip.addEventListener("pointermove", function (e) { if (dragX !== null) strip.scrollLeft = from - (e.clientX - dragX); });
strip.addEventListener("pointerup", function () { dragX = null; strip.style.scrollSnapType = ""; });
if (matchMedia("(prefers-reduced-motion: reduce)").matches || !matchMedia("(hover: hover) and (pointer: fine)").matches) return;
var cur = root.querySelector(".w2lbl-cur"), txt = root.querySelector(".w2lbl-txt"), cards = root.querySelectorAll("[data-label]");
var x = 0, y = 0, s = 0, tx = 0, ty = 0, label = "", hot = null, live = false, frame = 0, idle = 0, t0 = performance.now();
function loop(now) {
var o = root.getBoundingClientRect(), target = hot;
if (!live) {
var t = Math.max(0, now - t0) / IDLE_MS, c = cards[Math.floor(t) % cards.length].getBoundingClientRect();
target = cards[Math.floor(t) % cards.length];
tx = c.left - o.left + c.width * (0.42 + 0.12 * Math.sin(t * 3)); ty = c.top - o.top + c.height * 0.4;
}
var want = target ? target.getAttribute("data-label") : "";
if (want && want !== label) { label = want; txt.textContent = want; s *= 0.6; }
x += (tx - x) * EASE; y += (ty - y) * EASE; s += ((target ? 1 : 0) - s) * 0.18;
cur.style.transform = "translate(" + x + "px," + y + "px) scale(" + s + ")";
frame = requestAnimationFrame(loop);
}
function start() { if (!frame) frame = requestAnimationFrame(loop); }
function stop() { cancelAnimationFrame(frame); frame = 0; }
new IntersectionObserver(function (e) { e[0].isIntersecting ? start() : stop(); }).observe(root);
root.addEventListener("pointermove", function (e) {
if (e.pointerType === "touch") return;
var o = root.getBoundingClientRect();
tx = e.clientX - o.left; ty = e.clientY - o.top; hot = e.target.closest("[data-label]");
live = true; clearTimeout(idle); root.setAttribute("data-live", ""); root.removeAttribute("data-kb");
});
root.addEventListener("pointerleave", function () { hot = null; root.removeAttribute("data-live"); idle = setTimeout(function () { live = false; }, 1500); });
// Keyboard: the label steps aside; each card's own chip already says what it does.
root.addEventListener("focusin", function () { if (root.querySelector(":focus-visible")) root.setAttribute("data-kb", ""); });
root.addEventListener("focusout", function () { root.removeAttribute("data-kb"); });
})();
</script>
With reduced motion: No disc appears; the printed chips and normal cursors explain each card.
Running cost: One element moved with transform and a rectangle read per frame; the loop stops off screen.
- Change any card's `data-label` attribute to set its word; the disc reads it live.
- Resize the disc with `--w2lbl-size` (92px in React) and recolour it with `--w2lbl-ink`.
- Raise `IDLE_MS` to let the preview demo linger longer on each card.
Magnifier Loupe Over a Price List
A round brass-rimmed loupe glides over a seed merchant's printed price list and shows the lines beneath it at almost twice the size. Inside the lens is a second copy of the same list, scaled and slid with transform so it lines up exactly with the spot under the pointer. Handy for dense menus, spec sheets or catalogue pages with lots of small print.
<section class="w2lup-root" data-w2lup>
<div class="w2lup-wrap">
<div class="w2lup-head">
<div>
<p class="w2lup-label">Aldergrove Seed Co.</p>
<h2>The fine print, up close</h2>
</div>
<a href="#" class="w2lup-btn">Order a seed box</a>
</div>
<div class="w2lup-sheet">
<div class="w2lup-list">
<div class="w2lup-top">
<h3>Spring sowing list</h3>
<p>Price per packet</p>
</div>
<ul>
<li><span><b>Broad bean, Winter Lantern</b><i>Sow Feb to Apr. Thirty seeds.</i></span><em>$3.40</em></li>
<li><span><b>Pea, Hedgerow Sugar</b><i>Sweet flat pods, climbs to 5 ft.</i></span><em>$3.10</em></li>
<li><span><b>Beetroot, Cellar Blood</b><i>Deep red globes that store well.</i></span><em>$2.80</em></li>
<li><span><b>Carrot, Long Barn</b><i>Tapered roots for heavy soil.</i></span><em>$2.60</em></li>
<li><span><b>Lettuce, Velvet Oak</b><i>Pick-again leaves, bronze tips.</i></span><em>$2.90</em></li>
<li><span><b>Chard, Five Lamps</b><i>Stems in gold, pink and white.</i></span><em>$3.00</em></li>
<li><span><b>Tomato, Ridge Cherry</b><i>Small fruit, early, very sweet.</i></span><em>$3.80</em></li>
<li><span><b>Squash, Pale Moon</b><i>Grey-blue skin, dense orange flesh.</i></span><em>$3.60</em></li>
<li><span><b>Leek, Frost Hold</b><i>Stands all winter in the bed.</i></span><em>$2.70</em></li>
<li><span><b>Kale, Black Crow</b><i>Crinkled leaves, sweeter after frost.</i></span><em>$2.90</em></li>
<li><span><b>Sweet pea, Old Parlour</b><i>Strong scent, mixed soft colours.</i></span><em>$3.50</em></li>
<li><span><b>Calendula, Ember Mix</b><i>Edible petals, self-seeds gently.</i></span><em>$2.40</em></li>
</ul>
</div>
<div class="w2lup-lens" aria-hidden="true"></div>
</div>
</div>
</section>
<style>
/* Change these: --w2lup-lens (loupe diameter; keep LENS in the script equal), --w2lup-paper (sheet), --w2lup-ink (text and rim). ZOOM is in the script. */
.w2lup-root { --w2lup-lens: 240px; --w2lup-paper: #fbf6ec; --w2lup-ink: #2b2117;
background: #e9dfcd; color: var(--w2lup-ink); padding: 56px 20px; font-family: system-ui, sans-serif; }
@media (min-width: 640px) { .w2lup-root { padding: 64px 40px; } }
.w2lup-wrap { max-width: 64rem; margin: 0 auto; }
.w2lup-head { margin-bottom: 32px; display: flex; flex-wrap: wrap; gap: 16px; align-items: end; justify-content: space-between; }
.w2lup-label { margin: 0; font-size: .75rem; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: #7a4b22; }
.w2lup-head h2 { margin: 8px 0 0; font-family: Georgia, serif; font-weight: 400; font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1.2; }
.w2lup-btn { display: inline-flex; min-height: 44px; align-items: center; padding: 0 20px; border-radius: 6px; background: var(--w2lup-ink); color: #f6efe2;
font-size: .875rem; font-weight: 600; text-decoration: none; }
.w2lup-btn:focus-visible { outline: 2px solid #7a4b22; outline-offset: 3px; }
.w2lup-sheet { position: relative; overflow: hidden; border-radius: 2px; background: var(--w2lup-paper); box-shadow: 0 1px 0 rgba(43,33,23,.12), 0 24px 50px -30px rgba(43,33,23,.6); }
.w2lup-list { padding: 24px 20px; }
@media (min-width: 640px) { .w2lup-list { padding: 32px; } }
.w2lup-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; justify-content: space-between; padding-bottom: 12px; border-bottom: 2px solid #3b2f22; }
.w2lup-top h3 { margin: 0; font-family: Georgia, serif; font-size: 1.25rem; }
.w2lup-top p { margin: 0; font-size: .75rem; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: #6b5641; }
.w2lup-list ul { margin: 8px 0 0; padding: 0; list-style: none; display: grid; column-gap: 40px; }
@media (min-width: 768px) { .w2lup-list ul { grid-template-columns: 1fr 1fr; } }
.w2lup-list li { display: flex; gap: 12px; align-items: baseline; padding: 10px 0; border-bottom: 1px dotted #b9a68c; }
.w2lup-list li span { flex: 1; min-width: 0; }
.w2lup-list b { display: block; font-size: .9375rem; }
.w2lup-list i { display: block; font-size: .8125rem; color: #5c4a37; }
.w2lup-list em { font-style: normal; font-size: .9375rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.w2lup-lens { position: absolute; left: 0; top: 0; width: var(--w2lup-lens); height: var(--w2lup-lens); border-radius: 50%; overflow: hidden; pointer-events: none;
background: var(--w2lup-paper); opacity: 0; transition: opacity .35s ease; will-change: transform;
box-shadow: 0 0 0 5px #3b2f22, 0 0 0 6px rgba(255,255,255,.25), 0 18px 40px -10px rgba(43,33,23,.55); }
.w2lup-lens::after { content: ""; position: absolute; inset: 0; border-radius: 50%;
background: radial-gradient(circle at 32% 26%, rgba(255,255,255,.45), rgba(255,255,255,0) 42%), radial-gradient(circle, rgba(0,0,0,0) 62%, rgba(43,33,23,.18) 100%); }
.w2lup-lens > .w2lup-list { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.w2lup-root[data-on] .w2lup-lens { opacity: 1; }
.w2lup-root[data-kb] .w2lup-lens { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .w2lup-lens { display: none; } }
</style>
<script>
(function () {
var root = document.querySelector("[data-w2lup]");
if (!root) return;
var ZOOM = 1.8; // magnification inside the loupe
var LENS = 240; // loupe diameter in px, same as --w2lup-lens
var EASE = 0.18; // how closely the loupe follows the pointer
if (matchMedia("(prefers-reduced-motion: reduce)").matches || !matchMedia("(hover: hover) and (pointer: fine)").matches) return;
var sheet = root.querySelector(".w2lup-sheet"), lens = root.querySelector(".w2lup-lens");
// The loupe shows a scaled copy of the list, hidden from assistive tech.
var clone = sheet.querySelector(".w2lup-list").cloneNode(true);
lens.appendChild(clone);
root.setAttribute("data-on", "");
var R = LENS / 2, x = 0, y = 0, tx = 0, ty = 0, live = false, frame = 0, idle = 0, t0 = performance.now();
function fit() { clone.style.width = sheet.clientWidth + "px"; }
function loop(now) {
if (!live) {
var t = (now - t0) / 1000;
tx = sheet.clientWidth * (0.5 + 0.38 * Math.sin(t * 0.42)); ty = sheet.clientHeight * (0.5 + 0.36 * Math.sin(t * 0.9 + 0.5));
}
x += (tx - x) * EASE; y += (ty - y) * EASE;
lens.style.transform = "translate(" + (x - R) + "px," + (y - R) + "px)";
clone.style.transform = "translate(" + (R - x * ZOOM) + "px," + (R - y * ZOOM) + "px) scale(" + ZOOM + ")";
frame = requestAnimationFrame(loop);
}
function start() { if (!frame) frame = requestAnimationFrame(loop); }
function stop() { cancelAnimationFrame(frame); frame = 0; }
fit(); new ResizeObserver(fit).observe(sheet);
new IntersectionObserver(function (e) { e[0].isIntersecting ? start() : stop(); }).observe(root);
sheet.addEventListener("pointermove", function (e) {
if (e.pointerType === "touch") return;
var r = sheet.getBoundingClientRect(); tx = e.clientX - r.left; ty = e.clientY - r.top;
live = true; clearTimeout(idle); root.removeAttribute("data-kb");
});
sheet.addEventListener("pointerleave", function () { idle = setTimeout(function () { live = false; }, 1500); });
root.addEventListener("focusin", function () { if (root.querySelector(":focus-visible")) root.setAttribute("data-kb", ""); });
root.addEventListener("focusout", function () { root.removeAttribute("data-kb"); });
})();
</script>
With reduced motion: The loupe stays hidden and the list reads at its normal size.
Running cost: Two elements moved with transform per frame, though the scaled copy doubles the text the browser keeps in memory.
- Change `ZOOM` to 1.5 for a gentle lens or 3 for a strong one.
- Resize the loupe with `--w2lup-lens` and keep `LENS` in the script at the same number.
- Swap the list items for your own; the copy inside the lens is made from the same markup, so it updates with them.
Pointer Spotlight Over a Dimmed Photo
A barrel room photograph sits in near darkness and a soft pool of light follows the pointer, so visitors explore the racks the way a cellar hand would with a lamp. The darkness is one oversized gradient layer that slides with transform, which keeps it smooth on large screens. On phones the light rests in place and jumps to wherever you tap.
<section class="w2spt-root" data-w2spt>
<img class="w2spt-photo" src="https://images.pexels.com/photos/2946621/pexels-photo-2946621.jpeg?auto=compress&cs=tinysrgb&w=1600" alt="Oak wine barrels with red wine stains racked four high on steel frames in a cellar" loading="lazy" width="1600" height="1084">
<div class="w2spt-shade" aria-hidden="true"></div>
<div class="w2spt-side" aria-hidden="true"></div>
<div class="w2spt-copy">
<p class="w2spt-label">Harrow Ridge Cellars</p>
<h2>The barrel room opens for evening tastings</h2>
<p class="w2spt-text">Walk the racks by lamplight with our cellar hand, then taste three wines drawn straight from the cask.</p>
<div class="w2spt-ctas">
<a href="#" class="w2spt-btn">Book an evening</a>
<a href="#" class="w2spt-btn w2spt-ghost">See the wines</a>
</div>
<p class="w2spt-small">Thursday to Saturday, from six</p>
</div>
</section>
<style>
/* Change these: --w2spt-dark (the dimmed colour), --w2spt-r (spotlight radius), --w2spt-gold (button and label colour). */
.w2spt-root { --w2spt-dark: 14, 9, 7; --w2spt-r: 260px; --w2spt-gold: #e6c48f;
position: relative; overflow: hidden; min-height: 600px; background: rgb(var(--w2spt-dark)); color: #f5ede2; font-family: system-ui, sans-serif;
display: flex; align-items: flex-end; }
.w2spt-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* The shade is twice the size of the section and centred on its top-left corner; the script slides that centre to the pointer. */
.w2spt-shade { position: absolute; left: -100%; top: -100%; width: 200%; height: 200%; pointer-events: none; will-change: transform;
background: radial-gradient(circle var(--w2spt-r) at 50% 50%, rgba(var(--w2spt-dark), 0) 0%, rgba(var(--w2spt-dark), .2) 45%, rgba(var(--w2spt-dark), .9) 100%); }
.w2spt-side { position: absolute; inset: 0; pointer-events: none;
background: linear-gradient(0deg, rgba(var(--w2spt-dark), .95) 0%, rgba(var(--w2spt-dark), .85) 55%, rgba(var(--w2spt-dark), .1) 100%); }
@media (min-width: 640px) { .w2spt-side { background: linear-gradient(90deg, rgba(var(--w2spt-dark), .92) 0%, rgba(var(--w2spt-dark), .6) 38%, rgba(var(--w2spt-dark), 0) 62%); } }
.w2spt-copy { position: relative; max-width: 30rem; padding: 48px 20px; }
@media (min-width: 640px) { .w2spt-copy { padding: 64px 48px; } }
.w2spt-label { margin: 0; font-size: .75rem; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: var(--w2spt-gold); }
.w2spt-copy h2 { margin: 14px 0 0; font-family: Georgia, "Times New Roman", serif; font-weight: 400; font-size: clamp(2rem, 4.6vw, 3rem); line-height: 1.1; }
.w2spt-text { margin: 16px 0 0; font-size: 1rem; line-height: 1.65; color: #e3d8ca; }
.w2spt-ctas { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 12px; }
.w2spt-btn { display: inline-flex; min-height: 44px; align-items: center; padding: 0 22px; border-radius: 4px; background: var(--w2spt-gold);
color: #1c130d; font-size: .875rem; font-weight: 600; text-decoration: none; }
.w2spt-ghost { background: rgba(20,13,10,.55); color: #f5ede2; border: 1px solid rgba(245,237,226,.4); }
.w2spt-btn:focus-visible { outline: 2px solid #f5ede2; outline-offset: 3px; }
.w2spt-small { margin: 20px 0 0; font-size: .8125rem; color: #cfc2b2; }
@media (prefers-reduced-motion: reduce) { .w2spt-shade { display: none; } }
</style>
<script>
(function () {
var root = document.querySelector("[data-w2spt]");
if (!root) return;
var EASE = 0.1; // how softly the light trails the pointer (0 to 1)
if (matchMedia("(prefers-reduced-motion: reduce)").matches) return;
var shade = root.querySelector(".w2spt-shade");
var fine = matchMedia("(hover: hover) and (pointer: fine)").matches;
var W = root.clientWidth, H = root.clientHeight, x = W * .7, y = H * .4, tx = x, ty = y;
var live = false, frame = 0, idle = 0, t0 = performance.now();
function place() { shade.style.transform = "translate(" + x + "px," + y + "px)"; }
function loop(now) {
W = root.clientWidth; H = root.clientHeight;
if (!live) {
var t = (now - t0) / 1000;
tx = W * (0.68 + 0.2 * Math.sin(t * 0.5)); ty = H * (0.45 + 0.25 * Math.sin(t * 0.8 + 1));
}
x += (tx - x) * EASE; y += (ty - y) * EASE; place();
frame = requestAnimationFrame(loop);
}
function start() { if (!frame) frame = requestAnimationFrame(loop); }
function stop() { cancelAnimationFrame(frame); frame = 0; }
function at(e) { var r = root.getBoundingClientRect(); tx = e.clientX - r.left; ty = e.clientY - r.top; }
if (!fine) {
// Touch: the light rests in one spot and moves to wherever someone taps.
place();
root.addEventListener("pointerdown", function (e) { at(e); x = tx; y = ty; shade.style.transition = "transform .6s ease"; place(); });
return;
}
new IntersectionObserver(function (e) { e[0].isIntersecting ? start() : stop(); }).observe(root);
root.addEventListener("pointermove", function (e) { if (e.pointerType !== "touch") { at(e); live = true; clearTimeout(idle); } });
root.addEventListener("pointerleave", function () { idle = setTimeout(function () { live = false; t0 = performance.now(); }, 1500); });
})();
</script>
With reduced motion: The darkened layer is removed and the whole photo shows behind the copy.
Running cost: A single gradient layer moved with transform, so the gradient is painted once and only composited after that.
- Change `--w2spt-r` (or `RADIUS` in React) to widen or tighten the pool of light.
- Edit the last stop of the shade gradient, `.9`, to make the unlit area darker or let more of the photo show through.
- Raise `EASE` toward 0.25 so the light keeps up with fast hands, or lower it for a lazier lamp.
Precision Crosshair With Coordinate Readout
Full-length guide lines cross under the pointer on a sample artboard, snapping to an 8 pixel grid, while a small tag beside them reads out the X and Y position and markers slide along both rulers. It sells a layout or design tool in its own hero. Keyboard users can focus the board and nudge the crosshair with the arrow keys, and a tap places it on touch screens.
<section class="w2crs-root" data-w2crs>
<div class="w2crs-grid">
<div class="w2crs-copy">
<p class="w2crs-label">Gridwell</p>
<h2>Place every element to the pixel, then forget about it.</h2>
<p class="w2crs-text">A layout tool for print and screen with an 8 point grid, true rulers and guides that stay where you put them.</p>
<a href="#" class="w2crs-btn">Start a blank board</a>
</div>
<div class="w2crs-frame">
<div class="w2crs-ruler w2crs-rx" aria-hidden="true"><span class="w2crs-mx"></span></div>
<div class="w2crs-ruler w2crs-ry" aria-hidden="true"><span class="w2crs-my"></span></div>
<div class="w2crs-board" tabindex="0" role="group" aria-label="Sample artboard. Arrow keys move the crosshair by 8 pixels, hold Shift for 40.">
<div class="w2crs-art" aria-hidden="true">
<i style="left:8%;top:8%;width:30%;height:6%"></i>
<i style="left:62%;top:8%;width:30%;height:6%;opacity:.5"></i>
<i class="w2crs-img" style="left:8%;top:22%;width:50%;height:44%"></i>
<i style="left:62%;top:22%;width:30%;height:4%"></i>
<i style="left:62%;top:30%;width:26%;height:4%;opacity:.5"></i>
<i style="left:62%;top:38%;width:28%;height:4%;opacity:.5"></i>
<i class="w2crs-cta" style="left:62%;top:54%;width:20%;height:9%"></i>
<i style="left:8%;top:74%;width:84%;height:4%;opacity:.4"></i>
<i style="left:8%;top:82%;width:60%;height:4%;opacity:.4"></i>
</div>
<span class="w2crs-h" aria-hidden="true"></span>
<span class="w2crs-v" aria-hidden="true"></span>
<span class="w2crs-c" aria-hidden="true"></span>
<span class="w2crs-tag" aria-hidden="true">X 0 Y 0</span>
</div>
<p class="w2crs-sr" aria-live="polite"></p>
</div>
</div>
</section>
<style>
/* Change these: --w2crs-line (crosshair colour), --w2crs-board (artboard), --w2crs-dark (page). GRID in the script sets the snap step. */
.w2crs-root { --w2crs-line: #c03d1f; --w2crs-board: #f4f4f1; --w2crs-dark: #1b1c1f;
background: var(--w2crs-dark); color: #ececea; padding: 56px 20px; font-family: system-ui, sans-serif; }
@media (min-width: 640px) { .w2crs-root { padding: 72px 40px; } }
.w2crs-grid { max-width: 72rem; margin: 0 auto; display: grid; gap: 40px; align-items: center; }
@media (min-width: 900px) { .w2crs-grid { grid-template-columns: 22rem 1fr; gap: 56px; } }
.w2crs-label { margin: 0; font-size: .75rem; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: #f08a74; }
.w2crs-copy h2 { margin: 14px 0 0; font-size: clamp(1.75rem, 3.6vw, 2.5rem); line-height: 1.12; letter-spacing: -.02em; font-weight: 650; }
.w2crs-text { margin: 16px 0 0; line-height: 1.65; color: #b9bab6; }
.w2crs-btn { margin-top: 28px; display: inline-flex; min-height: 44px; align-items: center; padding: 0 20px; border-radius: 6px; background: #ececea; color: #1b1c1f;
font-size: .875rem; font-weight: 600; text-decoration: none; }
.w2crs-btn:focus-visible, .w2crs-board:focus-visible { outline: 2px solid #7fb4ff; outline-offset: 4px; }
.w2crs-frame { position: relative; padding: 20px 0 0 20px; }
.w2crs-ruler { position: absolute; overflow: hidden; background-color: #26272b; }
.w2crs-rx { left: 20px; right: 0; top: 0; height: 20px; background-image: repeating-linear-gradient(90deg, #5a5c63 0 1px, transparent 1px 8px), repeating-linear-gradient(90deg, #8a8c93 0 1px, transparent 1px 64px);
background-size: 100% 6px, 100% 12px; background-position: 0 100%, 0 100%; background-repeat: repeat-x; }
.w2crs-ry { top: 20px; bottom: 0; left: 0; width: 20px; background-image: repeating-linear-gradient(180deg, #5a5c63 0 1px, transparent 1px 8px), repeating-linear-gradient(180deg, #8a8c93 0 1px, transparent 1px 64px);
background-size: 6px 100%, 12px 100%; background-position: 100% 0, 100% 0; background-repeat: repeat-y; }
.w2crs-mx, .w2crs-my { position: absolute; left: 0; top: 0; background: var(--w2crs-line); }
.w2crs-mx { width: 1px; height: 20px; } .w2crs-my { width: 20px; height: 1px; }
.w2crs-board { position: relative; height: 380px; overflow: hidden; border-radius: 2px; background-color: var(--w2crs-board);
background-image: linear-gradient(rgba(0,0,0,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(0,0,0,.05) 1px, transparent 1px); background-size: 8px 8px; }
.w2crs-art i { position: absolute; border-radius: 3px; background: #c9cac4; }
.w2crs-art .w2crs-img { background: linear-gradient(135deg, #b9c3c9, #8f9ca5); }
.w2crs-art .w2crs-cta { background: #2b2c30; border-radius: 999px; }
.w2crs-h, .w2crs-v, .w2crs-c, .w2crs-tag { position: absolute; left: 0; top: 0; pointer-events: none; will-change: transform; }
.w2crs-h { width: 100%; height: 1px; background: var(--w2crs-line); }
.w2crs-v { width: 1px; height: 100%; background: var(--w2crs-line); }
.w2crs-c { width: 11px; height: 11px; margin: -5px 0 0 -5px; border: 1px solid var(--w2crs-line); background: var(--w2crs-board); }
.w2crs-tag { padding: 3px 7px; border-radius: 3px; background: var(--w2crs-line); color: #fff; font: 600 11px/1.4 ui-monospace, Menlo, monospace; white-space: pre; }
.w2crs-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); margin: 0; }
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) { .w2crs-board[data-live] { cursor: none; } }
</style>
<script>
(function () {
var root = document.querySelector("[data-w2crs]");
if (!root) return;
var GRID = 8; // snap step in px
var BIG = 40; // step with Shift held
var board = root.querySelector(".w2crs-board"), sr = root.querySelector(".w2crs-sr");
var q = function (s) { return root.querySelector(s); };
var h = q(".w2crs-h"), v = q(".w2crs-v"), c = q(".w2crs-c"), tag = q(".w2crs-tag"), mx = q(".w2crs-mx"), my = q(".w2crs-my");
// No idle drift for reduced motion or touch screens: the crosshair rests until moved.
var still = matchMedia("(prefers-reduced-motion: reduce)").matches || !matchMedia("(hover: hover) and (pointer: fine)").matches;
var X = 0, Y = 0, live = false, frame = 0, idle = 0, t0 = performance.now();
function set(x, y) {
var W = board.clientWidth, H = board.clientHeight;
X = Math.max(0, Math.min(W - 1, Math.round(x / GRID) * GRID)); Y = Math.max(0, Math.min(H - 1, Math.round(y / GRID) * GRID));
h.style.transform = "translateY(" + Y + "px)"; v.style.transform = mx.style.transform = "translateX(" + X + "px)";
c.style.transform = "translate(" + X + "px," + Y + "px)"; my.style.transform = "translateY(" + Y + "px)";
tag.textContent = "X " + X + " Y " + Y;
tag.style.transform = "translate(" + (X > W - 120 ? X - 104 : X + 12) + "px," + (Y > H - 40 ? Y - 30 : Y + 12) + "px)";
}
function loop(now) {
var t = (now - t0) / 1000;
set(board.clientWidth * (0.5 + 0.36 * Math.sin(t * 0.45)), board.clientHeight * (0.5 + 0.34 * Math.sin(t * 0.8 + 0.6)));
frame = requestAnimationFrame(loop);
}
function start() { if (!frame && !live && !still) frame = requestAnimationFrame(loop); }
function stop() { cancelAnimationFrame(frame); frame = 0; }
function take() { live = true; stop(); clearTimeout(idle); }
set(board.clientWidth * 0.62, board.clientHeight * 0.4);
new IntersectionObserver(function (e) { e[0].isIntersecting ? start() : stop(); }).observe(root);
board.addEventListener("pointermove", function (e) {
var r = board.getBoundingClientRect(); take(); board.setAttribute("data-live", "");
set(e.clientX - r.left, e.clientY - r.top);
});
board.addEventListener("pointerdown", function (e) { var r = board.getBoundingClientRect(); take(); set(e.clientX - r.left, e.clientY - r.top); });
board.addEventListener("pointerleave", function () { board.removeAttribute("data-live"); idle = setTimeout(function () { live = false; start(); }, 2000); });
// Keyboard: arrows nudge the crosshair along the grid, and the new position is announced.
board.addEventListener("keydown", function (e) {
var d = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[e.key];
if (!d) return;
e.preventDefault(); take();
var s = e.shiftKey ? BIG : GRID;
set(X + d[0] * s, Y + d[1] * s);
sr.textContent = "X " + X + ", Y " + Y;
});
})();
</script>
With reduced motion: The idle drift is off; the crosshair rests in place and moves only when you point, tap or press an arrow key.
Running cost: Five small elements moved with transform and one text update per move; the idle loop stops for real input and off screen.
- Change `GRID` to snap to a coarser or finer step; set it to 1 for free movement.
- Recolour the lines, rulers and tag through `--w2crs-line`, keeping white text on it readable.
- Replace the grey placeholder blocks inside `.w2crs-art` with a real screenshot of your own interface.
Spring Chain Ribbon Trail
A sailmaker's hero on deep harbour navy with a sand-coloured ribbon that chases the pointer. The head of the ribbon rides a spring toward the mouse and every link eases after the one ahead, so quick moves make it overshoot and swing like a rope in wind. It tapers and fades toward the tail and loops through the space by itself until someone takes over.
<section class="w7rbn" data-w7rbn aria-label="Tidewater Sail Loft">
<div class="w7rbn-rope" aria-hidden="true"></div>
<div class="w7rbn-body">
<p class="w7rbn-eye">Tidewater Sail Loft</p>
<h2 class="w7rbn-h">Sails cut for the water you actually sail</h2>
<p class="w7rbn-p">We measure your boat at its mooring, ask where you go and how hard you push, then cut and stitch each panel in our loft above the harbour chandlery.</p>
<div class="w7rbn-row">
<a class="w7rbn-btn" href="#">Ask for a quote</a>
<a class="w7rbn-ghost" href="#">Book a repair</a>
</div>
<ul class="w7rbn-tags">
<li>Cruising dacron</li><li>Racing laminates</li><li>Winter repairs</li>
</ul>
</div>
</section>
<style>
/* Change these: --w7rbn-bg, --w7rbn-ink, --w7rbn-rope (ribbon colour). Stiffness, damping and length are in the script. */
.w7rbn { --w7rbn-bg: #10213a; --w7rbn-ink: #eef1f4; --w7rbn-rope: #e2c79a;
position: relative; height: 560px; overflow: hidden; background: radial-gradient(120% 90% at 85% 10%, #1a3254 0%, var(--w7rbn-bg) 60%); color: var(--w7rbn-ink);
font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; display: flex; align-items: center; touch-action: pan-y; }
.w7rbn-rope { position: absolute; inset: 0; pointer-events: none; }
.w7rbn-rope i { position: absolute; left: 0; top: 0; width: 100px; border-radius: 99px; background: var(--w7rbn-rope); transform-origin: 0 50%; will-change: transform; }
.w7rbn-body { position: relative; width: 100%; max-width: 64rem; margin: 0 auto; padding: 32px 20px; }
.w7rbn-eye { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .22em; text-transform: uppercase; color: var(--w7rbn-rope); }
.w7rbn-h { margin: 14px 0 0; max-width: 15ch; font-size: clamp(2.3rem, 6.2vw, 4.4rem); font-weight: 600; line-height: 1.02; letter-spacing: -.03em; }
.w7rbn-p { margin: 20px 0 0; max-width: 32rem; font-size: 16px; line-height: 1.65; color: #c4ccd8; }
.w7rbn-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.w7rbn-btn, .w7rbn-ghost { display: inline-flex; align-items: center; min-height: 48px; padding: 0 24px; border-radius: 6px; font-weight: 600; font-size: 15px; text-decoration: none; }
.w7rbn-btn { background: var(--w7rbn-rope); color: #1b1408; }
.w7rbn-btn:hover { background: #efd8b0; }
.w7rbn-ghost { color: var(--w7rbn-ink); border: 1px solid rgba(238,241,244,.35); }
.w7rbn-ghost:hover { border-color: var(--w7rbn-ink); }
.w7rbn-btn:focus-visible, .w7rbn-ghost:focus-visible { outline: 3px solid var(--w7rbn-ink); outline-offset: 3px; }
.w7rbn-tags { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 36px 0 0; padding: 0; list-style: none; font-size: 13px; letter-spacing: .06em; color: #9fb0c5; }
@media (min-width: 720px) { .w7rbn-body { padding: 40px 48px; } }
@media (prefers-reduced-motion: reduce) { .w7rbn-rope i { will-change: auto; } }
</style>
<script>
(function () {
var root = document.querySelector("[data-w7rbn]");
if (!root) return;
var off = [];
//BODY-START
var N = 36, STIFF = .08, LINK = .3, DAMP = .82, IDLE_AFTER = 1800; // links, head pull, pull between links, motion kept per frame, ms before the demo resumes
var reduce = matchMedia("(prefers-reduced-motion: reduce)").matches;
var layer = root.querySelector(".w7rbn-rope"), segs = [], P = [];
for (var i = 0; i < N; i++) {
P.push({ x: 0, y: 0, vx: 0, vy: 0 });
if (!i) continue;
var s = document.createElement("i"), f = 1 - i / N;
s.style.height = (3 + 13 * f).toFixed(1) + "px";
s.style.marginTop = -(1.5 + 6.5 * f).toFixed(1) + "px";
s.style.opacity = (.2 + .8 * f).toFixed(2);
layer.appendChild(s); segs.push(s);
}
off.push(function () { layer.textContent = ""; });
function path(t) { var w = root.clientWidth, h = root.clientHeight; return [w * (.62 + .28 * Math.sin(t * .0011)), h * (.5 + .32 * Math.sin(t * .0022))]; }
function draw() {
for (var i = 1; i < N; i++) {
var a = P[i - 1], b = P[i], dx = a.x - b.x, dy = a.y - b.y;
segs[i - 1].style.transform = "translate(" + b.x.toFixed(1) + "px," + b.y.toFixed(1) + "px) rotate(" + Math.atan2(dy, dx).toFixed(3) + "rad) scaleX(" + ((Math.hypot(dx, dy) + 2) / 100).toFixed(3) + ")";
}
}
if (reduce) {
// A still, gently curved ribbon drawn once.
for (var r = 0; r < N; r++) { var w = root.clientWidth; P[r].x = w * .9 - r * w * .018; P[r].y = root.clientHeight * (.3 + .12 * Math.sin(r / 4)); }
draw(); return;
}
var tx = 0, ty = 0, real = 0, raf = 0, seen = true;
var s0t = performance.now(), s0 = path(s0t);
P.forEach(function (p) { p.x = s0[0]; p.y = s0[1]; });
function sim(t) {
if (!real || t - real > IDLE_AFTER) { var q = path(t); tx = q[0]; ty = q[1]; }
var h = P[0];
h.vx = (h.vx + (tx - h.x) * STIFF) * DAMP; h.vy = (h.vy + (ty - h.y) * STIFF) * DAMP;
h.x += h.vx; h.y += h.vy;
// Every later link eases toward the one ahead of it, so the chain trails and swings behind the head.
for (var i = 1; i < N; i++) { P[i].x += (P[i - 1].x - P[i].x) * LINK; P[i].y += (P[i - 1].y - P[i].y) * LINK; }
}
function tick(t) { raf = requestAnimationFrame(tick); sim(t); draw(); }
// Run the demo for a second up front so the ribbon is already flowing in the first frame.
for (var j = 70; j > 0; j--) sim(s0t - j * 16.7);
draw();
function aim(x, y) { var b = root.getBoundingClientRect(); tx = x - b.left; ty = y - b.top; real = performance.now(); }
function move(e) { aim(e.clientX, e.clientY); }
function focus(e) { var r = e.target.getBoundingClientRect(); aim(r.left + r.width / 2, r.bottom + 16); real += 4000; }
function leave() { real = 0; }
root.addEventListener("pointermove", move);
root.addEventListener("pointerdown", move);
root.addEventListener("pointerleave", leave);
root.addEventListener("focusin", focus);
off.push(function () { root.removeEventListener("pointermove", move); root.removeEventListener("pointerdown", move); root.removeEventListener("pointerleave", leave); root.removeEventListener("focusin", focus); });
function play() { if (!raf && seen) raf = requestAnimationFrame(tick); }
function stop() { cancelAnimationFrame(raf); raf = 0; }
var io = new IntersectionObserver(function (e) { seen = e[0].isIntersecting; if (seen) play(); else stop(); });
io.observe(root);
off.push(stop, function () { io.disconnect(); });
play();
//BODY-END
})();
</script>
With reduced motion: A single curved ribbon rests in the top right corner and does not follow anything.
Running cost: Twenty-three transforms per frame from a tiny spring loop; it stops when the section leaves the screen.
- Lengthen the ribbon with `N`, make it snappier with `STIFF`, and give the head more swing by raising `DAMP` toward 0.9; a lower `LINK` makes the tail trail further behind.
- Recolour it with `--w7rbn-rope`; the taper and fade are set per link when the chain is built.
- Move the demo loop by editing the two `Math.sin` factors in `path`.
Performance notes
Pointer events can fire faster than the screen refreshes. These effects store the latest position and draw once per frame, then stop the frame loop entirely when the pointer leaves or the section scrolls out of view. That keeps an idle page at zero work.
Followers move with translate3d and never touch left or top, so the browser does not recalculate layout each frame. Trails reuse a fixed pool of elements or one canvas instead of creating nodes as the mouse moves, which keeps memory flat however long someone plays with them.
Questions
How do I make a custom cursor in CSS?
For a static image, the cursor property with a url() and a fallback keyword is enough. Anything that moves smoothly, lags behind or changes shape needs a small script that positions an element under the pointer, which is what the effects on this page do.
Should I hide the default cursor?
Only when your replacement clearly marks the click point, and only for a fine pointer such as a mouse. Keep it visible on touch screens, for keyboard users and when motion is reduced. Every effect here follows those rules out of the box.
Do cursor effects work on phones?
Phones have no hovering pointer, so a follower has nothing to follow. These effects detect pointer: coarse and either stay off or turn a tap into a brief ripple, and the content underneath works exactly as it does without them.
Can a cursor trail slow my site down?
It can if it creates new elements on every mouse move or animates layout properties. A pooled trail drawn once per frame with transforms or on a single canvas costs very little, and pausing it when off screen removes the cost entirely.
More collections: CSS Hover Effects and Magnetic Buttons, Expanding Cards and Image Panels, Scroll Animations Without a Library. All cursor effects. Build your site free to have a full site built around them.
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App