React Text Trail Effect
Three.js-powered text effect that creates fluid trails following mouse movement with customizable noise and persistence. Perfect for interactive typography.
Building fluid text interactions?
Join our Discord community for help from other developers.
Most interactive text effects are limited to basic CSS transforms that feel disconnected from user input. This component creates fluid trail effects using WebGL shaders and Three.js, making text respond organically to mouse movement with customizable persistence and noise.
WebGL-powered fluid trails
Text that creates smooth flowing trails that follow cursor movement:
Built with TypeScript for React applications, using Three.js and custom GLSL shaders for high-performance WebGL rendering with real-time noise generation and fluid dynamics.
Installation
npx shadcn@latest add https://www.shadcn.io/registry/text-trail.json
npx shadcn@latest add https://www.shadcn.io/registry/text-trail.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/text-trail.json
bunx shadcn@latest add https://www.shadcn.io/registry/text-trail.json
Usage
import TextTrail from "@/components/text/text-trail";
<div className="flex items-center justify-center min-h-screen w-full">
<div className="relative w-full h-full">
<TextTrail
text="shadcn/ui"
fontFamily="Inter"
fontWeight="900"
noiseFactor={1.2}
noiseScale={0.001}
rgbPersistFactor={0.95}
alphaPersistFactor={0.92}
animateColor={false}
textColor="#ffffff"
backgroundColor="#000000"
supersample={2}
/>
</div>
</div>
Why basic interactions fall short
Traditional text interactions use CSS hover effects or simple JavaScript animations—approaches that can't create the fluid, organic trail effects that make typography feel truly responsive to user input. Static transforms lack the dynamic persistence and noise that creates compelling visual feedback.
This React component uses WebGL shaders to render text with fluid trail effects that smoothly follow mouse movement. The trails persist and fade over time with customizable noise patterns, creating organic distortion that makes text feel alive and responsive to user interaction.
The key insight: WebGL shaders enable real-time fluid effects. When text trails are generated using GPU-accelerated shaders with noise functions, they create more convincing organic movement than CSS or canvas-based approaches can achieve.
Features
- High-performance WebGL rendering with Three.js and custom GLSL shaders for smooth 60fps effects
- Real-time fluid trail generation with customizable persistence factors for RGB and alpha channels
- Advanced noise generation using simplex noise algorithms for organic distortion patterns
- Interactive mouse tracking with smooth interpolation and customizable response sensitivity
- Animated color cycling support with configurable intervals for dynamic visual effects
- Responsive design with automatic scaling and high-DPI display support via supersample factor
- Free open source component compatible with Next.js and shadcn/ui design systems
API Reference
TextTrail
WebGL-based fluid text trail component with mouse interaction.
Prop | Type | Default | Description |
---|---|---|---|
text | string | 'Trail' | Text content to display |
fontFamily | string | 'Figtree' | Font family name |
fontWeight | string | number | '900' | Font weight value |
noiseFactor | number | 1 | Noise intensity multiplier |
noiseScale | number | 0.0005 | Noise frequency scale |
rgbPersistFactor | number | 0.98 | RGB color trail persistence (0-1) |
alphaPersistFactor | number | 0.95 | Alpha trail persistence (0-1) |
animateColor | boolean | false | Enable color cycling animation |
startColor | string | '#ffffff' | Initial text color |
textColor | string | '#ffffff' | Static text color (disables cycling) |
backgroundColor | number | string | 0x271e37 | Canvas background color |
colorCycleInterval | number | 3000 | Color change interval (ms) |
supersample | number | 2 | Rendering quality multiplier |
Trail Persistence
Control how long trails remain visible:
Factor | Range | Visual Effect | Best For |
---|---|---|---|
Short | 0.8-0.9 | Quick fade, sharp trails | Fast interactions, clean look |
Medium | 0.9-0.95 | Balanced persistence | General use, smooth trails |
Long | 0.95-0.99 | Slow fade, fluid trails | Artistic effects, slow movement |
Infinite | 0.99+ | Permanent trails | Static displays, buildup effects |
Noise Configuration
Organic distortion pattern settings:
Property | Range | Effect | Recommended For |
---|---|---|---|
noiseFactor | 0.5-2.0 | Overall noise strength | 0.8-1.2 for subtle, 1.5+ for dramatic |
noiseScale | 0.0001-0.01 | Noise detail level | 0.0005 for smooth, 0.005+ for chaotic |
Common gotchas
WebGL context loss: The component handles context restoration automatically, but multiple instances or complex scenes might cause context issues. Consider limiting simultaneous instances or using a shared WebGL context.
Performance on mobile: WebGL rendering with shaders is GPU-intensive. On mobile devices, consider reducing supersample factor, increasing persistence factors (less frequent updates), or providing a fallback for low-end devices.
Font loading delays: The component waits for font loading before rendering. Custom fonts might cause initial delays. Preload fonts in your HTML head or use font-display: swap for better perceived performance.
Three.js bundle size: This component adds Three.js to your bundle (~500KB gzipped). Consider code splitting or lazy loading if not using Three.js elsewhere in your application.
Color format consistency: backgroundColor accepts both hex strings and numeric values. Ensure consistent format usage across your application for predictable results.
Integration with other components
Perfect for hero sections with dramatic interactive typography or accent elements in dark-themed Card layouts. The fluid trails work excellently against dark backgrounds where the light text creates strong contrast.
For creative interfaces, combine with other interactive elements that respond to mouse movement. The component pairs well with Badge components for status indicators with trails and works beautifully in full-screen Dialog modals for dramatic reveals.
Questions developers actually ask
React Text Reveal
Interactive text reveal with cursor-based animations. Perfect for React applications requiring dynamic text reveals with TypeScript support.
React True Focus Effect
Spotlight-style text effect with blur transitions and targeting brackets that focus attention on one word at a time. Perfect for emphasis and presentations.