Installation
- Tab Title
- Tab Title
Usage
Props
Custom cursor content. If not provided, a default arrow cursor is rendered.
Spring physics configuration for the cursor animation.
Spring Configuration Details
Controls how quickly the cursor settles. Higher values create more damping (slower settling).
Controls the spring’s strength. Higher values make the cursor respond faster.
Controls the cursor’s inertia. Higher values make it feel heavier.
Threshold for considering the animation complete.
Examples
Default Cursor
Custom Cursor Icon
Custom Spring Physics
Snappy Cursor
Floaty Cursor
Image Cursor
How It Works
- Native Cursor Hidden: The component sets
body { cursor: none }to hide the default cursor - Mouse Tracking: Global
mousemoveevent listener tracks cursor position - Velocity Calculation: Calculates movement speed and direction
- Spring Physics: Uses
motion-svsprings for smooth, natural motion - Rotation: Cursor rotates based on movement direction
- Scale Effect: Slightly scales down when moving fast
- RAF Throttling: Uses
requestAnimationFramefor optimized updates
Animation Behavior
Position
The cursor smoothly follows the mouse with spring physics applied to both X and Y coordinates.Rotation
The cursor rotates to align with the direction of movement. Rotation is accumulated to prevent sudden jumps when crossing the 0°/360° boundary.Scale
When moving quickly (velocity > 0.1), the cursor scales down to 0.95 and returns to 1.0 after 150ms of no fast movement.Features
- Smooth spring-based cursor tracking
- Automatic rotation based on movement direction
- Scale effects on fast movement
- Customizable cursor design
- Configurable spring physics
- Performance-optimized with RAF throttling
- Automatic cleanup on unmount
- Restores default cursor on unmount
- GPU-accelerated transforms
- Entrance animation on load
Performance
- Uses
requestAnimationFramefor throttled updates - GPU-accelerated with
will-change: transform - Fixed positioning for optimal rendering
- Pointer events disabled to prevent interference
- Efficient velocity calculations
Considerations
- The native cursor is hidden globally (
body { cursor: none }) - May not be suitable for all use cases (forms, text selection, etc.)
- Best used for landing pages, portfolios, or creative sites
- Consider accessibility implications
- Test on different devices (works best with mouse/trackpad)
Accessibility
This component hides the native cursor, which may impact accessibility:- Consider providing a toggle to disable the custom cursor
- Ensure sufficient contrast for visibility
- Test with keyboard navigation
- May not work well on touch devices
Browser Support
Works in all modern browsers that support:- CSS transforms
- RequestAnimationFrame
- ES6+ JavaScript features
- Motion-sv library requirements