Hover✨ Premium

Text Scramble

On hover, all letters simultaneously switch to random characters then reveal left to right during the hover, 30 ms per step.

JSTextDecode

Updated

This effect is part of Effect.Labs — 840 vanilla effects, some free, some premium. Hover has 48 effects, including 5 free. Explore the category →

3 usage examples

Navigation links — developer portfolio — Text Scramble example 1

① Navigation links — developer portfolio

WhenHovering each nav bar link scrambles then decodes its characters from left to right — the visitor gets a machine-like effect before landing on the target page.
WhyApplying scramble to small navigation links shows the effect works at any scale; it sets a developer portfolio apart from a designer portfolio without an extra image.
SettingsSystem font (-apple-system). 13 px size (small nav links). Base colour #94a3b8, hover colour #e2e8f0. Several independent .fx-0373-root instances within the same nav.
Auto-decoded KPI — SaaS dashboard — Text Scramble example 2

② Auto-decoded KPI — SaaS dashboard

WhenWhen the dashboard opens (IntersectionObserver), the three key numeric values (revenue, active accounts, churn) scramble then reveal in a cascade with a 180 ms offset between each figure.
WhyAn automatic decode on load turns a dashboard opening into a narrative intro: each figure "arrives" progressively, capturing attention without flickering or a classic transition.
Settings28 px size, sans-serif font. Automatic trigger via IntersectionObserver in <script data-scenes> (dispatch mouseenter on each .tsx-text with a progressive delay).
Quiz result — interactive card with a "Reveal" button — Text Scramble example 3

③ Quiz result — interactive card with a "Reveal" button

WhenIn a quiz interface, the user clicks "Reveal" to trigger the scramble on the correct answer label; characters scramble then reveal "Correct!" from left to right.
WhyA click-triggered scramble rather than hover creates extra tension before confirmation — the user actively chooses to see their result.
Settings18 px size, #818cf8 colour. Trigger: click on a separate button (wired in <script data-scenes>) that dispatches mouseenter on .tsx-text. No hover trigger on this element.

How it works

The .fx-0373-root frame holds a .tsx-text element with a data-text attribute containing the final text. On load, the script reads that attribute and assigns it as aria-label so screen readers always announce the final text, regardless of the visual state. The element gets tabindex="0" role="text" to be keyboard-focusable.

On mouseenter (or focus), the disintegration animation starts: each letter is randomly replaced by a character from the alphanumeric pool (36 characters: A-Z and 0-9) every 30 ms. The reinstallation animation starts on mouseleave (or blur): correct letters are restored left to right, one by one, at the same 30 ms pace. Hovering again during reinstallation interrupts it.

Under prefers-reduced-motion: reduce, the text instantly shows its final state with no intermediate animation: on hover, it jumps directly to the value in data-text. Enter and Space trigger the same scramble as hover/click, for keyboard accessibility.

Accessibility

  • Screen readers: the visible text (.tsx-visual) carries aria-hidden="true"; a visually hidden element (.tsx-sr) permanently holds the final text. Screen readers always read this real text — scrambled characters are never announced.
  • Keyboard: the element is focusable by Tab (tabindex="0"). focus and blur events trigger the same animations as mouseenter and mouseleave. Enter and Space can also trigger the scramble.
  • Reduced motion: under prefers-reduced-motion: reduce, no intermediate animation occurs; the final text is shown directly on hover and stays on mouse-out. Zero animated letter changes.
  • Semantics: the .tsx-text element is a focusable <div> with no extra ARIA role. If the effect is applied to a heading or a link, keep the native HTML semantics (<h2>, <a>) and apply the JS on top of it.

Browser compatibility

JS + CSS, under 1.5 KB, no dependency. Animations are driven by setInterval at 30 ms. Compatible with all modern browsers. Measured in Chromium 151, Firefox 153 and WebKit 26: disintegration and reinstallation identical in all three. The effect does not use requestAnimationFrame: the 30 ms pace is constant regardless of display frequency.

Chrome 60+✓ Full
Firefox 55+✓ Full
Safari 11+✓ Full
Edge 79+✓ Full
Mobile iOS 11+✓ Full (focus on tap)
Android Chrome 60+✓ Full

Without JavaScript, the .tsx-text element shows its text as-is, without animation. On mobile without hover, the effect fires on focus (tap on the element); it remains visible as long as the element is focused.

The code

HTML structure to paste into your page (the CSS + JS come with your purchase):

index.html — structure
<div class="fx-0373-root">
  <div class="tsx-text" data-text="Your text" tabindex="0">Your text</div>
</div>

One-time payment, no subscription — the code is yours forever

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Displayed text (HTML — data-text attribute) "HOVER ME" Replace with any text. The initial visible content can be the same (HOVER ME) or different — the scramble always shows the value of data-text as the final state.
Animation speed (JS — 30 ms per step) 30 ms per step Lower to 20 ms for a fast, snappy look; raise to 60 ms for a slow, contemplative decode.
Character pool (JS — chars array) A-Z and 0-9 (36 characters) Replace with symbols (!@#$%^&*) for a more esoteric look, digits only (0-9) for a numeric look, or characters from another language.
Font (CSS — font-family on .tsx-text) inherited from document A monospace font (Courier New, JetBrains Mono) is recommended: fixed-width characters prevent the text from vibrating laterally during scramble.
Trigger (JS — events) mouseenter / mouseleave + focus / blur To trigger on click instead of hover, replace the listeners with click. For an automatic animation on load, call the disintegration function without an event.

FAQ

Yes. Duplicate as many .fx-0373-root frames as needed; each instance is isolated by document.querySelectorAll. Each has its own data-text, its own interval and its own animation.
The final text is in the DOM (initial content of .tsx-text) and in the aria-label; search engines read it normally. Make sure the data-text value and the initial content are identical to avoid any confusion.
In a proportional font, each character has a different width: when letters are replaced by random characters, the word's total width changes with every step, making the whole text vibrate laterally. A monospace font keeps a constant width per character, eliminating that wobble.