
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
A powerful, modular JavaScript library for creating custom mouse cursors and trail effects
Interactive cursor trails with real-time parameter controls
A powerful, lightweight, and modular JavaScript library for creating custom mouse cursors and trail effects in web applications. Transform your user experience with smooth-following trails and customizable cursor styles.
cursorlab helpnpm install cursorlab
# Try the interactive demo!
cursorlab demo
<!-- Include in HTML -->
<script src="node_modules/cursorlab/browser.js"></script>
<script>
// Set a circle trail with custom properties
CursorLab.setCursorTrail('circle')
.setColor('#ff0000')
.setSize(20)
.setThickness(3)
.trailDelay(0.1)
.startTrail();
</script>
// Node.js / ES6 Module
const CursorLab = require('cursorlab');
// Create instance for advanced control
const cursor = new CursorLab();
cursor.setCursorTrail('star')
.setColor('#00ff00')
.setSize(25)
.startTrail();
CursorLab uses a modular approach where each property has its own method. This allows for maximum flexibility and clear, readable code.
setCursorTrail(type)Set the trail shape that follows your cursor.
Available Types:
'circle' - Hollow circle'circle-filled' - Filled circle'square' - Hollow square'square-filled' - Filled square'triangle' - Triangle shape'star' - Star shape'dot' - Small filled circleCursorLab.setCursorTrail('circle');
CursorLab.setCursorTrail('star');
setSize(widthOrRadius, height)Control the trail dimensions.
// Single parameter - sets radius for circles/dots, or size for squares/stars
CursorLab.setSize(20);
// Two parameters - sets width and height independently
CursorLab.setSize(30, 20); // 30px wide, 20px tall
setThickness(thickness)Set border thickness for hollow shapes.
CursorLab.setThickness(1); // Thin border
CursorLab.setThickness(5); // Thick border
setColor(color)Set the trail color using any CSS color format.
CursorLab.setColor('#ff0000'); // Hex
CursorLab.setColor('red'); // Named color
CursorLab.setColor('rgb(255,0,0)'); // RGB
CursorLab.setColor('hsl(0,100%,50%)'); // HSL
trailDelay(delay)Control how quickly the trail follows the cursor (0.01 = fast, 0.3 = slow).
CursorLab.trailDelay(0.05); // Fast following
CursorLab.trailDelay(0.1); // Normal speed
CursorLab.trailDelay(0.3); // Slow following
startTrail()Begin the trail animation. Call this after setting up your trail properties.
CursorLab.setCursorTrail('circle').setColor('blue').startTrail();
setCustomCursor(cursorType, param1, param2)Change the actual cursor appearance.
Built-in Cursors:
CursorLab.setCustomCursor('grab');
CursorLab.setCustomCursor('copy');
CursorLab.setCustomCursor('none'); // Hide cursor
Custom Crosshair:
// setCustomCursor('crosshair', thickness, length)
CursorLab.setCustomCursor('crosshair', 2, 15);
CursorLab.setCustomCursor('crosshair', 4, 25); // Thicker, longer
Image Cursors:
// Use any image as cursor
CursorLab.setCustomCursor('url(path/to/cursor.png), auto');
CursorLab.setCustomCursor('url(data:image/png;base64,iVBOR...), auto');
setCustomStyle(cssStyles)Apply advanced CSS styling.
Object Format:
CursorLab.setCustomStyle({
cursor: 'none',
'pointer-events': 'auto'
});
CSS String Format:
CursorLab.setCustomStyle(`
.cursorlab-trail {
filter: blur(2px) !important;
opacity: 0.7 !important;
animation: pulse 1s infinite !important;
}
@keyframes pulse {
0%, 100% { transform: translate(-50%, -50%) scale(1); }
50% { transform: translate(-50%, -50%) scale(1.2); }
}
`);
All methods return this, enabling powerful method chaining:
// Basic chaining
CursorLab.setCursorTrail('circle')
.setColor('#ff0000')
.setSize(20)
.startTrail();
// Complex combination
CursorLab.setCursorTrail('star')
.setColor('#9b59b6')
.setSize(25)
.setThickness(3)
.trailDelay(0.08)
.setCustomCursor('grab')
.setCustomStyle({cursor: 'none'})
.startTrail();
// Multiple effects
const cursor = new CursorLab();
cursor.setCursorTrail('triangle')
.setColor('#e74c3c')
.setSize(30, 25) // width, height
.trailDelay(0.12)
.setCustomCursor('crosshair', 3, 20)
.startTrail();
// Create new trail (replaces any existing trail)
CursorLab.setCursorTrail('circle').setColor('#ff0000').setSize(25).startTrail();
// Remove all trails (keeps cursor changes)
CursorLab.setDefault();
// Reset cursor to original
CursorLab.setNormalCursor();
// Remove everything and clean up
CursorLab.destroy();
// Check if any trail is active
if (CursorLab.isActive()) {
console.log('Trails are running');
}
CursorLab.setCursorTrail('star')
.setColor('#ff00ff')
.setSize(30)
.trailDelay(0.06)
.setCustomCursor('crosshair', 2, 18)
.setCustomStyle(`
.cursorlab-trail {
animation: rainbow 2s infinite !important;
}
@keyframes rainbow {
0% { filter: hue-rotate(0deg); }
100% { filter: hue-rotate(360deg); }
}
`)
.startTrail();
CursorLab.setCursorTrail('square')
.setColor('#f39c12')
.setSize(22)
.setThickness(4)
.trailDelay(0.15)
.setCustomStyle(`
.cursorlab-trail {
animation: spin 1s linear infinite !important;
}
@keyframes spin {
from { transform: translate(-50%, -50%) rotate(0deg); }
to { transform: translate(-50%, -50%) rotate(360deg); }
}
`)
.startTrail();
// Small fast dot
CursorLab.setCursorTrail('dot')
.setSize(8)
.setColor('#1abc9c')
.trailDelay(0.03)
.startTrail();
// Large slow circle
CursorLab.setCursorTrail('circle')
.setSize(40)
.setThickness(2)
.setColor('#e74c3c')
.trailDelay(0.25)
.startTrail();
// Uses a global instance automatically
CursorLab.setCursorTrail('circle').setColor('red').startTrail();
CursorLab.setDefault(); // Reset the trail
// Create separate instances for independent control
const cursor1 = new CursorLab();
const cursor2 = new CursorLab();
cursor1.setCursorTrail('circle').setColor('blue').startTrail();
cursor2.setCursorTrail('star').setColor('red').startTrail();
| Method | Parameters | Description |
|---|---|---|
setCursorTrail(type) | type: string | Set trail shape |
setSize(size) | size: number | Set uniform size |
setSize(width, height) | width: number, height: number | Set dimensions |
setThickness(thickness) | thickness: number | Set border thickness |
setColor(color) | color: string | Set trail color |
trailDelay(delay) | delay: number | Set follow speed |
startTrail() | - | Begin trail animation |
| Method | Parameters | Description |
|---|---|---|
setCustomCursor(type) | type: string | Set CSS cursor |
setCustomCursor('crosshair', thickness, length) | thickness: number, length: number | Custom crosshair |
setCustomCursor(imageUrl) | imageUrl: string | Image cursor |
setCustomStyle(styles) | styles: object|string | Custom CSS |
| Method | Parameters | Description |
|---|---|---|
setDefault() | - | Remove trail |
setNormalCursor() | - | Reset cursor |
destroy() | - | Clean up everything |
isActive() | - | Check if active |
CursorLab includes a built-in command-line interface for quick reference:
# After installation
npm install cursorlab
# Get comprehensive help
cursorlab help
# Open interactive demo in browser
cursorlab demo
# Check version
cursorlab version
The CLI provides:
cursorlab demoPerfect for quick reference while coding!
trailDelay(0.1) or higher for better performance on slower devicessetCustomStyle()destroy() when removing the trail to prevent memory leaksblur(), drop-shadow(), brightness()Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see the LICENSE file for details.
FAQs
A powerful, modular JavaScript library for creating custom mouse cursors and trail effects
The npm package cursorlab receives a total of 8 weekly downloads. As such, cursorlab popularity was classified as not popular.
We found that cursorlab 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
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.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.