Cursor Trail Effect Generator
Preview
// Cursor Trail Effect document.addEventListener('DOMContentLoaded', function() { // Create canvas element const canvas = document.createElement('canvas'); canvas.style.position = 'fixed'; canvas.style.top = '0'; canvas.style.left = '0'; canvas.style.pointerEvents = 'none'; canvas.style.zIndex = '9999'; document.body.appendChild(canvas); // Initialize canvas const ctx = canvas.getContext('2d'); canvas.width = window.innerWidth; canvas.height = window.innerHeight; // Variables for particles const particles = []; const mouse = { x: 0, y: 0 }; // Options (customizable) const options = { trailEffect: 'dots', particleCount: 15, particleSize: 10, particleColor: '#3b82f6', fadeSpeed: 0.95 }; // Update mouse position on move document.addEventListener('mousemove', function(e) { mouse.x = e.clientX; mouse.y = e.clientY; // Add new particle particles.push({ x: mouse.x, y: mouse.y, size: options.particleSize, alpha: 1 }); // Keep particles array at desired length if (particles.length > options.particleCount) { particles.splice(0, particles.length - options.particleCount); } }); // Handle window resize window.addEventListener('resize', function() { canvas.width = window.innerWidth; canvas.height = window.innerHeight; }); // Animation loop function animate() { // Clear canvas ctx.clearRect(0, 0, canvas.width, canvas.height); // Draw and update particles particles.forEach((particle, index) => { if (options.trailEffect === 'dots') { ctx.beginPath(); ctx.arc(particle.x, particle.y, particle.size * particle.alpha, 0, Math.PI * 2); ctx.fillStyle = `${options.particleColor}${Math.floor(particle.alpha * 255).toString(16).padStart(2, '0')}`; ctx.fill(); } else if (options.trailEffect === 'line') { if (index > 0) { const prevParticle = particles[index - 1]; ctx.beginPath(); ctx.moveTo(prevParticle.x, prevParticle.y); ctx.lineTo(particle.x, particle.y); ctx.strokeStyle = `${options.particleColor}${Math.floor(particle.alpha * 255).toString(16).padStart(2, '0')}`; ctx.lineWidth = particle.size * particle.alpha; ctx.stroke(); } } else if (options.trailEffect === 'glow') { ctx.beginPath(); const grd = ctx.createRadialGradient( particle.x, particle.y, 0, particle.x, particle.y, particle.size * 2 * particle.alpha ); grd.addColorStop(0, `${options.particleColor}${Math.floor(particle.alpha * 255).toString(16).padStart(2, '0')}`); grd.addColorStop(1, `${options.particleColor}00`); ctx.fillStyle = grd; ctx.arc(particle.x, particle.y, particle.size * 2 * particle.alpha, 0, Math.PI * 2); ctx.fill(); } // Update alpha particle.alpha *= options.fadeSpeed; }); // Remove faded particles for (let i = particles.length - 1; i >= 0; i--) { if (particles[i].alpha < 0.01) { particles.splice(i, 1); } } requestAnimationFrame(animate); } animate(); });
Trail Options
How to Use
1. Customize the cursor trail effect using the options panel
2. Copy the generated code in your preferred format (JavaScript, HTML, or React)
3. Add the code to your website to implement the cursor trail effect
Related Tools
Cursor Trail: Your Complete Solution
Enhance your website's interactivity and visual appeal with our customizable Cursor Trail tool. It creates a trailing visual effect following the user's mouse movements, ideal for creative or playful UI designs.
Why is it Useful?
A cursor trail adds visual flair and interaction, making your site more engaging. It’s especially useful for:
- Improving user interaction on creative websites
- Adding fun animations for games or portfolios
- Enhancing user experience on landing pages
- Standing out with unique UI elements
Key Features
- Custom trail shapes: Choose from circles, emojis, images, or custom SVGs
- Adjust speed and length: Configure how fast and long the trail follows
- Color and animation: Use gradients or particle animations
- Lightweight: Optimized for minimal performance impact
- Copy-ready code: Generate and export for direct use in your project
How to Use?
- Select a trail type or upload a custom design
- Adjust trail speed, delay, and opacity settings
- Preview the cursor trail effect in real-time
- Copy the generated JavaScript/CSS code
- Paste the code into your project
Use Cases
Perfect for:
- Portfolios: Add a creative touch to your personal site
- Kids’ websites: Make learning or play websites more fun
- Marketing sites: Enhance user engagement on product pages
- Event sites: Make event websites more visually exciting
Benefits
- Boosts engagement: Keeps users interested and interacting
- Customizable: Matches the look and feel of any site
- Easy integration: Simple setup with copy-paste code
- No dependencies: Works standalone without libraries
- Performance-friendly: Optimized animations
Frequently Asked Questions
Can I upload my own cursor trail design?
Yes, the tool supports custom images and SVGs for trails.
Does it work on mobile devices?
Cursor trails are best suited for desktop experiences.
Is it free to use?
Yes, it's completely free and open for anyone to use.
Can I adjust the animation speed?
Yes, you can fully customize speed, delay, and fade time.
Is it easy to install on any site?
Absolutely. Just copy the provided JS/CSS and paste it into your HTML.