Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Text

Pro

Scrambled Text for React

Text that scrambles under the pointer, each character churning through glyphs and settling back behind it. For React with Base UI, when a paragraph should answer the pointer.

Framework

Scrambled Text is still until the pointer moves over it. Then the character under the pointer, and two on each side of it, churn through scrambled glyphs, dots and colons by default, and keep churning for a moment after the pointer moves on, so a short trail follows it across the line before the characters settle back. Hold the pointer still and the characters around it settle in place.

Use it for a paragraph or a heading that invites the pointer: a hero, a portfolio, a teaser. To decode a whole line once, on hover, in view or on load, use Decrypted Text; for zeros and ones, Binary Text. It's CSS only: every character is a window over a column of glyphs ending in itself. Near the pointer, a CSS keyframe animation the install adds to your stylesheet steps through the column; once the pointer has gone, a stepped transition runs it back, so there's no script and nothing random. With reduced motion the text stays still.

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Usage

import { ScrambledText } from "@/components/ui/scrambled-text";
<ScrambledText text="Move the pointer across these words." />

Demos

Characters

characters is what the scramble draws from: brackets and symbols for a terminal, 01 for bits. The default, .:, dissolves the letters into dust.

Preview width

Timing

steps is how many glyphs a character runs through before it settles, and speed how long each shows; together they're the length of the trail, 400 ms by default.

Preview width

Accessibility

Screen readers read the text once, from a visually hidden copy; the glyphs are hidden from them. The text is plain at rest and settles under a still pointer, so the effect never stands between a reader and the words, and every character keeps its own width, so the line never shifts. There's nothing to do with a keyboard: the text is simply there. With reduced motion nothing scrambles.

FAQ

How is it different from Decrypted Text?

Decrypted Text decodes the whole line, one character after another, when it's hovered, scrolled into view or loaded. Scrambled Text never plays by itself: only the characters near the pointer scramble, and the scramble follows the pointer along the line.

Which characters scramble?

The one under the pointer and two on each side of it, within the same word: at a space the scramble stops, and the next word takes it up as the pointer reaches it.

Why do characters keep scrambling after the pointer has gone?

That's the trail. A character out of the pointer's reach runs through its glyphs once more, steps of them at speed each, before it settles, so a sweep across the line leaves a short wake behind it.

Are the glyphs random?

They look it but aren't: each glyph is picked from characters by a small formula of the character's place and the step, so the server and the browser draw the same ones.

What happens on a touch screen?

A tap scrambles the characters around it, which settle back a moment later. Nothing else changes: the text reads the same as anywhere.

Which font suits it?

Any. In a monospaced font, such as font-mono, every glyph has the same width, so the scramble reads as one even block; in a proportional one, a glyph wider than its character is clipped to it.

What happens with reduced motion?

Nothing scrambles: the text stays as it is under the pointer.

API Reference

ScrambledText

<span> data-slot="scrambled-text"

PropType
textstring

The text.

characters?string

The characters the scramble draws from. @default ".:".

Default
".:"
speed?number

How long each scrambled character shows, in milliseconds. @default 40.

steps?number

How many scrambled characters a character runs through before it settles again.

Default
10
render?ReactElement | ((props: object, state: object) => ReactElement)

Replace the host element or compose it with another component.

Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string

Merged with the part's classes.

CSS variableType
--scrambled-text-speedstring

How long each scrambled character shows (40ms).

--scrambled-text-stepsstring
All 97 text effects