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:
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.
Prop | Type | Default | Description |
---|---|---|---|
radius | number | 100 | Detection radius in pixels |
duration | number | 1.2 | Base scramble duration in seconds |
speed | number | 0.5 | Scrambling animation speed |
scrambleChars | string | '.:'' | Characters used for scrambling |
className | string | '' | Additional CSS classes |
style | React.CSSProperties | {} | Inline styles |
children | React.ReactNode | - | Text content to scramble |
Proximity Behavior
Distance-based interaction customization:
Radius | Effect | Best For |
---|---|---|
Small (50-80px) | Precise, close proximity | Subtle hover enhancements |
Medium (100-150px) | Natural mouse interaction | General interactive text |
Large (200px+) | Wide detection area | Dramatic, attention-grabbing effects |
Character Sets
Scramble pattern customization:
Character Set | Pattern | Visual 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.
Related text components you will also like
Decrypted Text
Matrix-style decryption effects with character cycling
Shuffle
Random character shuffling with smooth settling animations
Glitch Text
Digital glitch effects with RGB channel separation
Text Pressure
Pressure-sensitive text effects that respond to cursor distance
Variable Proximity
Font variation effects that respond to cursor proximity
Fuzzy Text
Soft blur transitions with particle-like text effects
Questions developers actually ask
React Rotating Text
React rotating text with smooth vertical transitions. Cycle through multiple phrases with clean animations using Motion, TypeScript, and shadcn/ui for Next.js apps.
React Scroll Velocity Text
Dynamic scrolling text that responds to scroll velocity. Perfect for React applications requiring engaging scroll-based animations.