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 🙏

© 2025 – Pkg Stats / Ryan Hefner

with-custom-cursor

v1.0.5

Published

A Higher-Order Component (HOC) library for React that enables you to easily add a custom cursor to any component.

Downloads

15

Readme

with-custom-cursor

A Higher-Order Component (HOC) library for React that enables you to easily add a custom cursor to any component.

with-custom-cursor logo

Features

  • Wrap any component with a custom cursor that follows mouse movement.
  • Fully typed with TypeScript.
  • Easy integration and customization.

Installation

npm install with-custom-cursor
# or
yarn add with-custom-cursor

Usage

1. Create Your Custom Cursor Component

import { type RefObject } from "react"

type CursorProps = {
    ref: RefObject<HTMLDivElement> // required to work!
}
export const Cursor = ({ ref }: CursorProps) => {
    return (
        <div className="cursor" ref={ref}>
            <label>see more</label>
        </div>
    )
}

2. Styling

.cursor {
    width: 16rem;
    height: 16rem;
    background-color: #fff;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    position: absolute;
    z-index: 9;
    display: flex;
}

.cursor label {
  color: #252525;    
  font-size: 1.8rem;
  font-weight: 400;
}

3. Wrap Your Component

import { WithCustomCursor } from "with-custom-cursor"
import { Cursor } from "./cursor"

const Card = () => {
    return (
        <div className="card">
            <h1>Card</h1>
            <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, voluptatibus.</p>
        </div>
    )
}

export const CardWithCursor = WithCustomCursor(Card, Cursor)

API

WithCustomCursor(WrappedComponent, CursorComponent)

  • WrappedComponent: The component you want to enhance with a custom cursor.
  • CursorComponent: The cursor component (must accept a ref prop).

Returns a new component that renders your cursor and the wrapped component.

Example

Adding Animations

Animating your custom cursor is straightforward with with-custom-cursor , as it is fully compatible with any React-friendly animation or CSS library.

1. Style Your Cursor Component

First, remove position: absolute and pointer-events: none from your cursor's style. These will be handled by the wrapper, allowing your cursor to animate freely:

.cursor {
    width: 16rem;
    height: 16rem;
    background-color: #fff;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    z-index: 9;
    display: flex;
}

2. Add Animation to Your Cursor

Wrap your cursor component in a <div> (recommended) or any html element with position: absolute and pointer-events: none (these styles were removed from the cursor itself). You can now use any animation library, such as framer-motion , tailwindcss , or gsap , etc... To animate your cursor.

Below is an example using framer-motion to create a pulsing effect:

import { motion } from "framer-motion"
import { type RefObject } from "react"

type CursorProps = {
    ref: RefObject<HTMLDivElement>
    label: string
    color?: string
}

export const Cursor = ({ label, color="white", ref}: CursorProps) => {
    return (
        <div ref={ref} style={{ position: "absolute", pointerEvents: "none" }}>
            <motion.div
            className="cursor"
            style={{ backgroundColor: color }}
            animate={{
                scale: [1, 1.2, 1]
            }}
            transition={{
                duration: 1.5,
                repeat: Infinity,
                ease: "easeInOut",
            }}
            >
                <label>{label}</label>
            </motion.div>
        </div>
        
    )
}

That's it! You can now add any animation to your custom cursor component. Feel free to experiment with different libraries and effects to achieve the look and feel you want.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

A special thanks to my friend Gabriel Chelles!

License

MIT © Andre Quintero dos Santos