Join our Discord Community

React Text Cursor Trail

Interactive cursor trail effect that leaves animated text or emojis following mouse movement with customizable spacing and floating animations.

Want to add interactive cursor effects?

Join our Discord community for help from other developers.


Most cursor effects are limited to basic CSS transforms or simple dot trails that feel generic and disconnected from your brand. This component creates customizable text or emoji trails that follow cursor movement with realistic spacing, directional rotation, and floating animations.

Animated cursor text trails

Interactive cursor effect that leaves customizable text or emoji trails:

Loading component...

Built with TypeScript for React applications, using Framer Motion for smooth animations and precise mouse tracking with configurable trail behavior, spacing, and visual effects.

Installation

npx shadcn@latest add https://www.shadcn.io/registry/text-cursor.json
npx shadcn@latest add https://www.shadcn.io/registry/text-cursor.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/text-cursor.json
bunx shadcn@latest add https://www.shadcn.io/registry/text-cursor.json

Usage

import TextCursor from "@/components/text/text-cursor";

<div className="relative w-full h-full">
  <TextCursor
    text="✨"
    delay={0.01}
    spacing={60}
    followMouseDirection={true}
    randomFloat={true}
    exitDuration={0.4}
    removalInterval={25}
    maxPoints={8}
  />
</div>

Why basic cursor effects are limiting

Traditional cursor effects use simple dot trails or basic CSS shadows—approaches that don't leverage the full potential of modern animation libraries. Generic cursor effects lack personality and fail to create the engaging, branded interactions that make interfaces memorable.

This React component creates customizable text or emoji trails that follow mouse movement with sophisticated animations. Each trail item can rotate to follow mouse direction, float with subtle random movement, and fade out gracefully, creating cursor effects that feel organic and branded to your application.

The key insight: cursor trails can carry meaning. When cursor effects use branded text, emojis, or symbols instead of generic dots, they become an extension of your interface's personality and create more memorable user experiences.

Features

  • Customizable text or emoji trails with smooth Framer Motion animations and realistic physics
  • Intelligent directional rotation that follows mouse movement for natural trailing behavior
  • Random floating animations with configurable intensity for organic movement patterns
  • Precise spacing control with distance-based trail point creation for consistent visual density
  • Configurable trail length with automatic cleanup and performance optimization
  • Responsive mouse tracking with container-relative positioning for accurate placement
  • Free open source component compatible with Next.js and shadcn/ui design systems

API Reference

TextCursor

Interactive cursor trail component with customizable text and animations.

PropTypeDefaultDescription
textstring'⚛️'Text or emoji to display in trail
delaynumber0.01Animation delay between trail items (seconds)
spacingnumber100Distance between trail points (pixels)
followMouseDirectionbooleantrueRotate trail items to follow mouse direction
randomFloatbooleantrueEnable subtle floating animations
exitDurationnumber0.5Fade out duration (seconds)
removalIntervalnumber30Trail cleanup interval (milliseconds)
maxPointsnumber5Maximum number of trail points

Trail Behavior

Mouse interaction and trail generation:

SettingEffectBest For
Close spacing (20-50px)Dense, continuous trailSmooth drawing effects
Medium spacing (50-100px)Balanced trail densityGeneral interactive elements
Wide spacing (100-200px)Sparse, discrete pointsSubtle accent effects

Animation Timing

Performance and visual smoothness:

ParameterRangeEffectRecommended
delay0-0.1sStagger between items0.01-0.05s for smooth
exitDuration0.2-1sFade out speed0.3-0.6s for natural
removalInterval10-50msCleanup frequency20-30ms for performance

Common gotchas

Performance with long trails: Each trail item creates an animated DOM element. Very long trails (maxPoints > 20) or rapid mouse movement can impact performance. Consider reducing maxPoints or increasing spacing for better performance.

Container positioning: The component uses container-relative mouse coordinates. Ensure the parent container has position: relative and defined dimensions, or trail positioning might be incorrect.

Mobile touch behavior: The component responds to mouse events only. Touch devices won't create trails during touch interactions. Consider adding touch event handlers or providing alternative interactions for mobile users.

Text rendering differences: Different fonts and emoji render with varying sizes. Test your chosen text across different browsers and devices to ensure consistent trail appearance.

Z-index layering: Trail items use pointer-events-none to avoid interfering with page interactions. Ensure proper z-index stacking if you need trails to appear above or below specific content.

Integration with other components

Perfect for creative interfaces, portfolio sites, or playful interactions in Card layouts. The cursor trails work excellently as accent elements that don't interfere with normal page functionality.

For gaming interfaces or creative tools, combine with other interactive elements that respond to mouse movement. The component pairs well with Button components for enhanced hover feedback and works beautifully in full-screen Dialog modals for immersive experiences.

Questions developers actually ask