Join our Discord Community

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:

Loading component...

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.

PropTypeDefaultDescription
textstring'Trail'Text content to display
fontFamilystring'Figtree'Font family name
fontWeightstring | number'900'Font weight value
noiseFactornumber1Noise intensity multiplier
noiseScalenumber0.0005Noise frequency scale
rgbPersistFactornumber0.98RGB color trail persistence (0-1)
alphaPersistFactornumber0.95Alpha trail persistence (0-1)
animateColorbooleanfalseEnable color cycling animation
startColorstring'#ffffff'Initial text color
textColorstring'#ffffff'Static text color (disables cycling)
backgroundColornumber | string0x271e37Canvas background color
colorCycleIntervalnumber3000Color change interval (ms)
supersamplenumber2Rendering quality multiplier

Trail Persistence

Control how long trails remain visible:

FactorRangeVisual EffectBest For
Short0.8-0.9Quick fade, sharp trailsFast interactions, clean look
Medium0.9-0.95Balanced persistenceGeneral use, smooth trails
Long0.95-0.99Slow fade, fluid trailsArtistic effects, slow movement
Infinite0.99+Permanent trailsStatic displays, buildup effects

Noise Configuration

Organic distortion pattern settings:

PropertyRangeEffectRecommended For
noiseFactor0.5-2.0Overall noise strength0.8-1.2 for subtle, 1.5+ for dramatic
noiseScale0.0001-0.01Noise detail level0.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