0.1.9 • Published 9 months ago

react-magic-cursor v0.1.9

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

React Magic Cursor

A cursor that follows your mouse and adapt its size, shape and color based on the hovered element.

Live Demo

See a real life example

Install

Depending on the package manager you are using for your project, use npm install or yarn add to include react-magic-cursor in your react app.

npm install --save react-magic-cursor
yarn add react-magic-cursor

Usage

Cursor

In your main location, add the MagicCursorProvider and MagicCursor

import React from 'react';
import { MagicCursor, MagicCursorProvider } from 'react-magic-cursor';

const App = () => {
  return (
    <React.StrictMode>
      <MagicCursorProvider thickness={2}>
        <div className="App">
          <MagicCursor />
          <Page />
        </div>
      </MagicCursorProvider>
    </React.StrictMode>
  );
};

Options

PropTypeDescriptionDefault
thicknessnumberthickness of the cursor1

This will add the cursor that follow the mouse.

Element

In order to interact with yours elements, you need to englobe them with the <MagicElement /> component.

import { MagicElement } from 'react-magic-cursor';

const Page = () => {
  return (
    <>
      <MagicElement type="outline" color="#ff0066" offset={5}>
        <button>Click me!</button>
      </MagicElement>

      <MagicElement type="underline" color="#ff0066">
        <a href="#">Follow me!</a>
      </MagicElement>
    </>
  );
};

Options

PropTypeDescriptionDefault
typestringoutline or underlineoutline
offsetnumbercan be negative0
colorstringhex value#000000

Contribute

  • Run the package locally
npm run dev

Visit http://localhost:5173/

  • Test the package in another project
npm run build && npm run pack

Then in your project's package.json file, add (refer to the current version in `./package.json):

"react-magic-cursor": "~/react-magic-cursor-0.1.5.tgz"

If you have a feature request, please add it as an issue or make a pull request.

Cheers!

0.1.8

9 months ago

0.1.7

9 months ago

0.1.9

9 months ago

0.1.6

9 months ago

0.1.4

11 months ago

0.1.5

11 months ago

0.1.43

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.0.11

1 year ago

0.0.12

1 year ago

0.0.13

1 year ago

0.0.14

1 year ago

0.1.0

1 year ago

0.1.1

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago