Encrypt Text

Letters scramble through a pool of random characters before settling on the target text, one character at a time.

ByMihirJaiswalUpdated

Loading...

Encrypt Text is a React text effect that scrambles each character through a pool of random glyphs — letters, digits, symbols — before settling on the target string. Settling fans out left-to-right so the final text reveals itself progressively, and whitespace is held constant so word shapes stay legible while surrounding letters are still scrambling.

Trigger it on mount, on hover, the first time it scrolls into view, or manually.

Installation

Usage

import { EncryptText } from "@/components/ui/encrypt-text";
 
export function Example() {
  return <EncryptText text="DESIGN SHARP · SHIP FAST" />;
}

Hover to replay

<EncryptText text="hover me" trigger="hover" />

Reveal on scroll into view

<EncryptText text="sliding into view…" trigger="inView" />

Custom character pool

<EncryptText text="HELLO" chars="01" tickMs={40} />
// → scrambles through 0s and 1s only

Play manually from a ref

const ref = useRef<EncryptTextHandle>(null);
 
<EncryptText ref={ref} text="ACCESS GRANTED" trigger="manual" />
<button onClick={() => ref.current?.play()}>Decrypt</button>

Props

PropTypeDefaultDescription
textstring—The final text to settle on.
charsstringletters + digits + symbolsPool of characters to sample while scrambling.
tickMsnumber55Milliseconds between scramble frames.
revealSecondsnumber0.9Total seconds over which the full reveal fans out.
trigger"mount" | "hover" | "inView" | "manual""mount"When to play the scramble.
startDelaynumber0Delay in ms before the first play.
asElementType"span"Element to render.
classNamestring—Extra classes.
scrambleClassNamestring"opacity-40"Classes for characters still scrambling.