Join our Discord Community

React Scrambled Text Effect

Interactive proximity-based text scrambling using GSAP's ScrambleText plugin. Characters scramble when cursor approaches with customizable radius and timing.

Want to create proximity-based text scrambling?

Join our Discord community for help from other developers.


Most interactive text effects respond to simple hover states that feel binary and disconnected from cursor position. This component creates proximity-based character scrambling that responds dynamically to cursor distance, making text feel reactive and organic to mouse movement.

Proximity-based character scrambling

Text that scrambles individual characters based on cursor proximity with customizable radius:

Loading component...

Built with TypeScript for React applications, using GSAP's SplitText and ScrambleTextPlugin for high-performance character-level scrambling with distance-based triggering and customizable scramble characters.

Installation

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

Usage

import ScrambledText from "@/components/text/scrambled-text";

<div className="flex items-center justify-center min-h-screen w-full p-4 sm:p-8">
  <ScrambledText
    className="text-center"
    radius={120}
    duration={1}
    speed={0.6}
    scrambleChars="!@#$%^&*()_+"
    style={{ 
      color: 'currentColor',
      fontSize: 'clamp(1rem, 3vw, 1.5rem)',
      fontFamily: 'inherit'
    }}
  >
    Move your cursor over this text to see the scrambling effect in action.
  </ScrambledText>
</div>

Why hover states feel disconnected

Traditional text interactions use binary on/off hover states—approaches that don't reflect the continuous nature of cursor movement and distance. Simple hover effects lack the organic, responsive quality that makes interactions feel natural and engaging.

This React component uses GSAP's ScrambleTextPlugin with distance calculations to create character-level scrambling that responds to cursor proximity. Characters scramble with intensity based on distance, creating smooth, organic interactions that feel connected to mouse movement.

The key insight: proximity-based interactions feel more natural. When text responds gradually to cursor distance rather than binary hover states, it creates more engaging and realistic interactive experiences.

Features

  • Proximity-based character scrambling with customizable detection radius and distance-based intensity
  • GSAP ScrambleTextPlugin integration for smooth character-level animations and performance optimization
  • Customizable scramble character sets with support for symbols, letters, numbers, or custom patterns
  • Responsive typography with clamp-based font sizing and flexible styling options
  • Distance-based animation timing where closer proximity creates faster scrambling effects
  • Performance optimized with character reuse and efficient event handling for smooth interactions
  • Free open source component compatible with Next.js and shadcn/ui design systems

API Reference

ScrambledText

Proximity-based text scrambling component with GSAP integration.

PropTypeDefaultDescription
radiusnumber100Detection radius in pixels
durationnumber1.2Base scramble duration in seconds
speednumber0.5Scrambling animation speed
scrambleCharsstring'.:''Characters used for scrambling
classNamestring''Additional CSS classes
styleReact.CSSProperties{}Inline styles
childrenReact.ReactNode-Text content to scramble

Proximity Behavior

Distance-based interaction customization:

RadiusEffectBest For
Small (50-80px)Precise, close proximitySubtle hover enhancements
Medium (100-150px)Natural mouse interactionGeneral interactive text
Large (200px+)Wide detection areaDramatic, attention-grabbing effects

Character Sets

Scramble pattern customization:

Character SetPatternVisual Effect
Symbols"!@#$%^&*()"Technical, coding aesthetic
Dots/Dashes".:_-"Minimal, clean scrambling
Numbers"0123456789"Digital, matrix-like effect
Letters"ABCDEFGHIJKLM"Alphabetic scrambling

Common gotchas

Performance with long text: Each character becomes an interactive element with distance calculations. Very long paragraphs (500+ characters) might impact performance on lower-end devices. Consider breaking long content into multiple components.

Mobile touch behavior: The component uses pointer events which work on touch devices, but the proximity effect behaves differently with touch since there's no hovering cursor. Consider providing alternative interactions for touch devices.

Font loading timing: Character scrambling depends on proper font metrics for distance calculations. Ensure fonts are loaded before the component initializes, or scrambling positions might be inaccurate.

Rapid mouse movement: Very fast cursor movement might skip over characters without triggering scrambling. The current implementation handles most cases, but extremely rapid movement might miss some characters.

Memory usage with complex scramble patterns: Using very long scrambleChars strings or complex character sets might increase memory usage. Keep character sets reasonably sized for optimal performance.

Questions developers actually ask