Components / Text
Text Scramble
Text that decodes from random characters, on mount or on hover.
ACCESS GRANTEDHover to scramble me
Installation
Requires React 18+ and Tailwind CSS.
- 1
Install dependencies
None. This component only needs React and Tailwind.
- 2
Add the component
Copy the code from the Code tab above into
components/ui/text-scramble.tsx. - 3
Use it
example.tsximport { TextScramble } from "@/components/ui/text-scramble"; export default function TextScrambleDemo() { return ( <div className="space-y-3 text-center"> <TextScramble text="ACCESS GRANTED" className="block text-3xl font-semibold text-zinc-900 dark:text-white" /> <TextScramble text="Hover to scramble me" trigger="hover" className="block cursor-default text-sm text-zinc-600 dark:text-zinc-400" /> </div> ); }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| text | string | — | The final text. |
| duration | number | 0.9 | Seconds until every character is revealed. |
| trigger | "mount" | "hover" | "mount" | Scramble once on mount, or every time the pointer enters. |