All effectsHover & follow

Blob Cursor

液态光标

A soft blob follows the pointer with a slight delay and stretches toward controls.

Move the pointer across the targets

Where to use it

Give a creative portfolio or studio site a custom pointer response. Keep the follower decorative and preserve the system pointer and visible keyboard focus.

Practical example

A design studio places a soft blue blob in its project finder. It drifts toward a project button as the pointer gets close.

Also called

  • Gooey Cursor
  • Liquid Cursor

AI prompt

Add a Blob Cursor to [section]. A soft, slightly lagging blob follows the pointer and stretches toward clickable targets. Keep the native cursor available. Hide the blob on touch devices and in reduced-motion mode.

Example code

Save the standalone HTML as a file and open it in your browser. It uses the same code as the preview.

View HTML
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Blob Cursor</title>
  <style>
    :root {
      color-scheme: dark;
      --demo-bg: #171629;
      --demo-ink: #f8f5ff;
      --demo-accent: #b9a6ff;
      --demo-muted: #bfbbd3;
      font-family: system-ui, sans-serif;
      color: var(--demo-ink);
      background: var(--demo-bg);
    }

    *, *::before, *::after { box-sizing: border-box; }
    body { margin: 0; min-width: 0; }
    button, input { font: inherit; }

    .demo {
      display: grid;
      place-items: center;
      align-content: center;
      min-height: 100vh;
      padding: 14px;
      overflow: hidden;
      background: radial-gradient(ellipse at 50% 24%, #28233f, var(--demo-bg) 78%);
    }

    .demo-button {
      border: 1px solid #ffffff3d;
      border-radius: 7px;
      background: #ffffff12;
      color: var(--demo-ink);
      padding: 6px 11px;
      font-size: 12px;
      cursor: pointer;
    }

    :focus-visible {
      outline: 2px solid var(--demo-accent);
      outline-offset: 3px;
    }

    .demo { background: #141e28; }
    .cursor-scene {
      position: relative;
      isolation: isolate;
      display: flex;
      justify-content: space-between;
      align-items: center;
      overflow: hidden;
      width: min(100%, 300px);
      height: min(66vh, 154px);
      padding: 21px;
      border: 1px solid #90aec239;
      border-radius: 16px;
      background:
        radial-gradient(circle, #879fb979 1px, transparent 1.2px) 50% 50% / 16px 16px,
        linear-gradient(120deg, #182a38, #0c1c28);
    }
    .cursor-target {
      z-index: 1;
      display: grid;
      place-items: center;
      width: 43px;
      height: 43px;
      padding: 0;
      border: 1px solid #a9c1d77a;
      border-radius: 13px;
      background: #132636d4;
      color: #d3efd6;
      cursor: pointer;
    }
    .cursor-target[aria-pressed='true'] { color: #1c3733; background: #c1f4bd; border-color: #c1f4bd; }
    .cursor-target > span { width: 12px; aspect-ratio: 1; border: 1.5px solid currentColor; }
    [data-shape='circle'] > span { border-radius: 50%; }
    [data-shape='diamond'] > span { transform: rotate(45deg); }
    .blob-sample, .cursor-blob {
      position: absolute;
      top: 0;
      left: 0;
      width: 50px;
      aspect-ratio: 1;
      border-radius: 58% 42% 46% 54% / 50% 56% 44% 50%;
      background: radial-gradient(circle at 29% 24%, #edffd4, #9decae 42%, #47b9a2 81%);
      box-shadow: inset -4px -4px 9px #448d78, 0 3px 15px #82e2b15c;
      pointer-events: none;
      transition: opacity .22s ease;
    }
    .blob-sample { top: 46%; left: 52%; transform: translate(-50%, -50%) rotate(-29deg) scale(1.3, .9); }
    .cursor-blob { opacity: 0; }
    .cursor-scene[data-following] .blob-sample { opacity: 0; }
    .cursor-scene[data-following] .cursor-blob { opacity: 1; }
    @media (prefers-reduced-motion: reduce), (hover: none), (pointer: coarse) {
      .blob-sample { transition: none; }
      .cursor-blob { display: none; }
    }
  </style>
</head>
<body>
  <main class="demo">
    <div class="cursor-scene">
      <span class="blob-sample" aria-hidden="true"></span>
      <span class="cursor-blob" aria-hidden="true"></span>
      <button class="cursor-target" type="button" aria-pressed="false" aria-label="Select circle" data-shape="circle"><span aria-hidden="true"></span></button>
      <button class="cursor-target" type="button" aria-pressed="false" aria-label="Select diamond" data-shape="diamond"><span aria-hidden="true"></span></button>
    </div>
  </main>
  <script>
    const scene = document.querySelector('.cursor-scene');
    const blob = document.querySelector('.cursor-blob');
    const targets = document.querySelectorAll('.cursor-target');
    const disable = matchMedia('(prefers-reduced-motion: reduce), (hover: none), (pointer: coarse)');
    let x = 0;
    let y = 0;
    let targetX = 0;
    let targetY = 0;
    let magnet = false;
    let stretch = 1;
    let angle = 0;
    let frame = 0;

    function follow() {
      frame = 0;
      const dx = targetX - x;
      const dy = targetY - y;
      const distance = Math.hypot(dx, dy);
      x += dx * .2;
      y += dy * .2;
      if (distance > 1) angle = Math.atan2(dy, dx);
      const desiredStretch = magnet ? 1.48 : 1 + Math.min(.57, distance / 90);
      stretch += (desiredStretch - stretch) * .23;
      blob.style.transform = 'translate(' + (x - 25) + 'px, ' + (y - 25) + 'px) rotate(' + angle + 'rad) scale(' + stretch + ', ' + (1 / Math.sqrt(stretch)) + ')';
      if (distance > .3 || Math.abs(stretch - desiredStretch) > .01) frame = requestAnimationFrame(follow);
    }
    scene.addEventListener('pointermove', (event) => {
      if (disable.matches || event.pointerType === 'touch') return;
      const bounds = scene.getBoundingClientRect();
      const target = event.target.closest('.cursor-target');
      const buttonBounds = target?.getBoundingClientRect();
      targetX = (buttonBounds ? (event.clientX + 2 * (buttonBounds.left + buttonBounds.width / 2)) / 3 : event.clientX) - bounds.left;
      targetY = (buttonBounds ? (event.clientY + 2 * (buttonBounds.top + buttonBounds.height / 2)) / 3 : event.clientY) - bounds.top;
      magnet = Boolean(target);
      if (!scene.hasAttribute('data-following')) {
        x = targetX;
        y = targetY;
        scene.setAttribute('data-following', '');
      }
      if (!frame) frame = requestAnimationFrame(follow);
    });
    function reset() {
      scene.removeAttribute('data-following');
      cancelAnimationFrame(frame);
      frame = 0;
      stretch = 1;
    }
    scene.addEventListener('pointerleave', reset);
    disable.addEventListener('change', reset);
    for (const target of targets) {
      target.addEventListener('click', () => {
        const pressed = target.getAttribute('aria-pressed') !== 'true';
        for (const other of targets) other.setAttribute('aria-pressed', String(other === target && pressed));
      });
    }
  </script>
</body>
</html>

Original example by UI Skills