Text Scramble
Scramble text through random characters and resolve it left to right, on mount, on view, on hover, or on demand.
Overview
Text Scramble cycles each character through random glyphs and settles them in reading order, the "decoding" effect used for status changes, build labels, and terminal-style navigation. Use it for short labels whose change is worth noticing. Avoid it on body text, where a reader would have to wait to read.
Every scrambling glyph is drawn over an invisible copy of its final character, so a random wide glyph such as W never pushes the line wider. The only change during a scramble is a pixel or two of lost kerning between characters, and settled text keeps its normal kerning. For a perfectly fixed width, use a monospaced font, which has no kerning. Spaces stay in place by default, so words keep their shape and long text still wraps between them.
Installation
Usage
import { TextScramble } from "@/components/animated/text-scramble"
<TextScramble>Deployment complete</TextScramble>Play it on hover or keyboard focus, for navigation links:
<a href="/settings">
<TextScramble trigger="hover" characters="01#/<>_=">
Settings
</TextScramble>
</a>Change children or replayKey to play it again, for example after a status update or a button press.
Accessibility
Assistive technology reads the final text from a visually hidden copy, and the scrambling characters are hidden from it. Screen readers never hear the random characters. The server and the first client render both show the final text, so the content is readable before JavaScript runs.
With reduced motion enabled, the text changes to its final value at once without scrambling.