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:
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.jsonnpx shadcn@latest add https://www.shadcn.io/registry/text-cursor.jsonpnpm dlx shadcn@latest add https://www.shadcn.io/registry/text-cursor.jsonbunx shadcn@latest add https://www.shadcn.io/registry/text-cursor.jsonUsage
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.
| Prop | Type | Default | Description |
|---|---|---|---|
text | string | '⚛️' | Text or emoji to display in trail |
delay | number | 0.01 | Animation delay between trail items (seconds) |
spacing | number | 100 | Distance between trail points (pixels) |
followMouseDirection | boolean | true | Rotate trail items to follow mouse direction |
randomFloat | boolean | true | Enable subtle floating animations |
exitDuration | number | 0.5 | Fade out duration (seconds) |
removalInterval | number | 30 | Trail cleanup interval (milliseconds) |
maxPoints | number | 5 | Maximum number of trail points |
Trail Behavior
Mouse interaction and trail generation:
| Setting | Effect | Best For |
|---|---|---|
| Close spacing (20-50px) | Dense, continuous trail | Smooth drawing effects |
| Medium spacing (50-100px) | Balanced trail density | General interactive elements |
| Wide spacing (100-200px) | Sparse, discrete points | Subtle accent effects |
Animation Timing
Performance and visual smoothness:
| Parameter | Range | Effect | Recommended |
|---|---|---|---|
| delay | 0-0.1s | Stagger between items | 0.01-0.05s for smooth |
| exitDuration | 0.2-1s | Fade out speed | 0.3-0.6s for natural |
| removalInterval | 10-50ms | Cleanup frequency | 20-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.
Related text components you will also like
Text Trail
Character trails that follow cursor movement
Text Pressure
Pressure-sensitive text effects that respond to cursor distance
Variable Proximity
Font variation effects that respond to cursor proximity
Scrambled Text
Proximity-based character scrambling with GSAP integration
Scroll Velocity
Text effects that respond to scroll speed and direction
Text Hover Effect
Interactive hover animations with character-level responses
Questions developers actually ask
React Splitting Text
React text splitting with staggered character, word, or line reveals. Smooth animations that flow naturally using Framer Motion, TypeScript, and shadcn/ui.
React Text Generate Effect
Progressive text generation with word-by-word reveals and blur effects. Perfect for React applications requiring dynamic content reveals.