React AnimeJS
Components/Scramble Text19 / 25

Scramble Text

uiIntermediateRead the docs

Code

1// Takes a target ref + a nested params object; returns { rescramble, isReady }.
2// No loop: each call decodes once. Call rescramble() to re-run (e.g. on shuffle).
3const { rescramble, isReady } = useAnimeScramble({
4 target: targetRef,
5 params: {
6 text: 'Hello World',
7 chars: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ!<>-_\\/[]{}—=+*^?#',
8 cursor: true,
9 },
10 autoplay: true,
11});
12
13<p ref={targetRef}>{text}</p>

Decoding character scramble with a custom charset and optional cursor.

Live preview
Scramble TextDecoding character scramble

Scramble Text

initializing…
Props
NameTypeDefaultDescription
targetRefObject<T>-Element ref to scramble (input)
params.textstring-Final text to decode into
params.charsstring-Scramble character set
params.cursorbooleanfalseShow a blinking cursor
autoplaybooleanfalseAuto-start on mount
rescramblefunction-Re-trigger the decode (returned)
isReadyboolean-True once the hook is initialized (returned)

Related components