Scramble Me!
The TextScramble component creates an engaging hover effect that scrambles text characters with random symbols before smoothly revealing the original text, perfect for interactive headings and eye-catching UI elements.
Installation
1npx shadcn@latest add "https://ace-ui-six.vercel.app/r/text-scramble.json"
Usage
1import { TextScramble } from "@/components/ui/text-scramble";23export default function ScrambleExample() {4return (5 <div className="flex justify-center items-center h-screen bg-gray-900 text-white">6 <TextScramble7 className="text-blue-400"8 speed={30}9 duration={800}10 >11 Hover Over This Text12 </TextScramble>13 </div>14);15}
Features
- Character scrambling animation on hover
- Customizable animation speed and duration
- Responsive text sizing with Tailwind breakpoints
- Smooth transition effects
- TypeScript support with full type safety
- Uses Jost font for modern typography
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | string | "Scramble Me!" | The text content to be scrambled |
speed | number | 50 | Animation speed in milliseconds between frames |
duration | number | 1000 | Total duration of the scramble effect in milliseconds |
className | string | "" | Additional CSS classes for styling |
Examples
Basic Usage
1<TextScramble>2Welcome to our site3</TextScramble>
Custom Speed and Duration
1<TextScramble2speed={25}3duration={1500}4className="text-green-400 hover:text-green-300"5>6Fast Scramble Effect7</TextScramble>
Large Heading
1<TextScramble className="text-6xl font-black text-gradient">2AMAZING TITLE3</TextScramble>