
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
cp-cursor is a versatile npm package designed to empower React developers with the ability to easily implement custom cursor pointers in any React project. With this package, you can effortlessly update styles, customize cursor icons, and explore a range
cp-cursor is an easy-to-use React package that provides a customizable and interactive custom cursor for your web applications. It allows you to replace the default browser cursor with a custom one that dynamically changes its appearance based on user interactions with different HTML elements like links, buttons, and input fields.
Leveraging react-icons, cp-cursor makes it simple to integrate a visually engaging cursor experience into your React projects.
react-icons.You can install cp-cursor using npm or yarn:
npm install cp-cursor react-icons
\# or
yarn add cp-cursor react-icons
Note: react-icons is a peer dependency, so make sure to install it alongside cp-cursor.
To use the custom cursor, simply import the Cursor component from cp-cursor and render it in your main application component (e.g., App.tsx or Layout.tsx).
// src/App.tsx
import React from 'react';
import { Cursor } from 'cp-cursor'; // Import the Cursor component
import './App.css'; // Your main CSS file
function App() {
return (
\<div className="App"\>
{/\* Your other application components \*/}
\<h1\>Welcome to my App\!\</h1\>
\<p\>This is some content.\</p\>
\<a href="\#"\>A link\</a\>
\<button\>A Button\</button\>
\<input type="text" placeholder="Type here..." /\>
\<Cursor /\> {/\* Render the Cursor component \*/}
\</div\>
);
}
export default App;
The useChangeIcon hook provides functions to dynamically change the cursor icons and their styles.
// src/components/MyCustomComponent.tsx (Example usage in a child component)
import React from 'react';
import { useChangeIcon } from 'cp-cursor';
import { FaBeer } from 'react-icons/fa'; // Example: using a different icon
const MyCustomComponent \= () \=\> {
const { changeCursor, changeCursorStyles } \= useChangeIcon();
const handleChangeIcons \= () \=\> {
// Change the 'hand' cursor icon to a beer icon
changeCursor('hand', \<FaBeer /\>);
};
const handleChangeStyles \= () \=\> {
// Change the cursor icon styles
changeCursorStyles({
iconSize: '30px',
borderColor: 'purple',
bgColor: 'yellow',
});
};
return (
\<div\>
\<button onClick={handleChangeIcons}\>Change Hand Icon\</button\>
\<button onClick={handleChangeStyles}\>Change Cursor Styles\</button\>
\</div\>
);
};
export default MyCustomComponent;
Important Notes:
Cursor component listens for mouse events on the entire document.tagName of the element being hovered over.cursor-box class is crucial for the component's internal logic. Do not remove it.Cursor ComponentThe Cursor component takes no props. It should be rendered once in your application.
useChangeIcon HookThe useChangeIcon hook returns an object with the following functions and state:
| Parameters | Default | Description |
|---|---|---|
iconSize | 20px | This is the size of the icon. |
borderColor | red | This is the border color of the icon. |
bgColor | black | This is the background color of the icon. |
changeCursor | hand, mouse, input | Function to change the icons. |
changeCursorStyles | default style | Update the styles of icons. |
default cursor | mouse | The default cursor icon displayed. |
hover actions | hand | Cursor icon when hovering over buttons, links (A, BUTTON). |
input action | input | Cursor icon for input fields (INPUT). |
Export to Sheets
changeCursor(cursorName: 'hand' | 'mouse' | 'input', icon: React.ReactElement | React.ReactNode):
cursorName: A string literal 'hand', 'mouse', or 'input', specifying which cursor icon to change.icon: A React.ReactElement or React.ReactNode (ideally a react-icons component) that will replace the default icon.changeCursor('hand', <GiHighFive />)changeCursorStyles(iconStyles: IconStyles):
iconStyles: An object of type IconStyles with the following properties: iconSize, borderColor, and bgColor. These directly correspond to the parameters detailed in the table above.changeCursorStyles({ iconSize: '25px', borderColor: 'blue', bgColor: 'lightgray' })cursorIcons: CursorIconTypes:
hand, mouse, input). This is primarily for internal use but can be accessed if needed.The Cursor component automatically manages which icon is displayed based on the element under the cursor:
mouse icon is displayed.<A> (links) or <BUTTON> elements, the hand icon is displayed.<INPUT> element, the input icon is displayed.// From types/index.ts (as inferred from your code)
/\*\*
\* @description
\* Position interface
\* Defines the x and y coordinates for the cursor's position.
\*/
export interface Position {
x: number;
y: number;
}
/\*\*
\* @description
\* IconVisibility interface
\* Defines the CSS display values for visible and hidden icon states.
\*/
export interface IconVisibility {
visible: string;
hidden: string;
}
/\*\*
\* @description
\* IconStyles interface
\* Defines the styling properties for cursor icons.
\*/
export interface IconStyles {
iconSize: string;
borderColor: string;
bgColor: string;
}
/\*\*
\* @description
\* CursorIconTypes interface
\* Defines the structure for different cursor icons as React elements.
\*/
export interface CursorIconTypes {
hand: React.ReactElement;
mouse: React.ReactElement;
input: React.ReactElement;
}
Contributions are welcome! If you find a bug, have a feature request, or want to improve the code, please feel free to:
git checkout -b feature/your-feature-name).git commit -m 'feat: Add new feature').git push origin feature/your-feature-name).This project is licensed under the GPL 3.0 License - see the LICENSE file for details.
react-icons for customizable iconsFAQs
cp-cursor is a versatile npm package designed to empower React developers with the ability to easily implement custom cursor pointers in any React project. With this package, you can effortlessly update styles, customize cursor icons, and explore a range
The npm package cp-cursor receives a total of 6 weekly downloads. As such, cp-cursor popularity was classified as not popular.
We found that cp-cursor demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.