npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

trailing-cursor

v1.0.2

Published

A customizable animated cursor trail for modern web apps.

Readme

🎯 trailing-cursor

A lightweight and customizable cursor trail effect that follows your mouse inside a specific container. Perfect for adding that extra flair to your UI.

✨ Features

  • 🌀 Smooth trailing animation
  • 🎨 Customizable color, size, and speed
  • 🚀 Enlarges on interactive elements (like buttons, links)
  • 🔒 Only activates inside a specific component or area
  • 👻 Auto hides outside the target
  • 🛠️ Zero dependencies, works in any framework (React, Svelte, Vanilla JS, etc.)

📦 Installation

npm install trailing-cursor

🚀 Quick Usage (React)

Wrap any component with a scoped to enable a custom cursor trail only within that area.

  1. Create a CursorTrail.jsx component:
// CursorTrail.jsx
import { useEffect, useRef } from "react";
import { initCursor } from "trailing-cursor";

export default function CursorTrail({ children, options = {} }) {
  const wrapperRef = useRef();

  useEffect(() => {
    const wrapper = wrapperRef.current;
    if (!wrapper) return;

    // Ensure relative positioning for cursor placement
    const computed = getComputedStyle(wrapper);
    if (computed.position === "static") {
      wrapper.style.position = "relative";
    }

    const destroy = initCursor({
      ...options,
      target: wrapper,
    });

    return () => destroy();
  }, [options]);

  return (
    <div ref={wrapperRef} style={{ overflow: "hidden", minHeight: "200px" }}>
      {children}
    </div>
  );
}
  1. Use it in your App:
import CursorTrail from "./CursorTrail";
import YourComponent from "./YourComponent";

function App() {
  return (
    <>
      <CursorTrail options={{ color: "#00f0ff", size: "25px", speed: 0.15 }}>
        <YourComponent />
      </CursorTrail>

      {/* Other components not affected by the trail */}
      <main>Content without the trail</main>
    </>
  );
}

Svelte Usage

<script>
    import { onMount, onDestroy } from 'svelte';
    import { initCursor } from 'trailing-cursor';
  
    let wrapper;
    let destroy;
  
    onMount(() => {
      const computed = getComputedStyle(wrapper);
      if (computed.position === 'static') {
        wrapper.style.position = 'relative'; // Ensure relative positioning
      }
  
      destroy = initCursor({
        target: wrapper,
        color: '#00f0ff',
        size: '20px',
        speed: 0.2,
        hoverSize: '55px',
      });
    });
  
    onDestroy(() => {
      destroy?.();
    });
  </script>
  
  <style>
    .cursor-area {
      min-height: 300px;
      overflow: hidden;
      border: 2px dashed #ccc;
      padding: 2rem;
      position: relative; /* ensure this exists if not handled in JS */
    }
  </style>
  
  <div bind:this={wrapper} class="cursor-area">
    <h2>Move your cursor around me!</h2>
    <button>Hover Me</button>
  </div>
  

🧩 Options

| Option | Type | Default | Description | |:------------|:--------:|--------------:|:---------------------------------------------------------------------| | target | element | | The DOM element within which the trailing cursor effect should be active. If not provided, defaults to document.body. | | color | string | "#fff" | The color of the trail circles. Accepts any valid CSS color. | | size | string | "20px" | The base size of each trail circle. Use CSS units like px, etc. | | speed | number | 0.2 | Speed of the trail movement. | | hoverSize | string | "50px" | Size of the trail when hovering over interactive elements. |


✨ Features

  • ✅ Scoped to any container
  • 🎨 Custom color and size
  • 🐢 Adjustable smoothness/speed
  • 🧲 Grows on interactive elements
  • 🖱️ Cursor-aware (disappears when outside)
  • 💻 Zero dependencies
  • 🪄 Easy to integrate into any framework

📦 For Other Frameworks

Use the initCursor({ target, ...options }) directly by importing it:

import { initCursor } from "trailing-cursor";

const destroy = initCursor({
  target: document.getElementById("my-area"),
  color: "hotpink",
  size: "24px",
});

Don't forget to call destroy() to clean it up if you're mounting/unmounting dynamically.

🧹 Cleanup

The function returned by initCursor() should be called when you no longer need the trail (e.g., on component unmount):

const destroy = initCursor({ ... });
destroy(); // Clean removal