shadcn.io is not affiliated with official shadcn/ui
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.
Installation
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.
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.
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.
API Reference
ScrambledText
<span> data-slot="scrambled-text"
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.
--scrambled-text-speedstring
How long each scrambled character shows (40ms).
--scrambled-text-stepsstringRelated
- Pro
Decrypted Text
DecodeDecode a whole line once
- Pro
Binary Text
DecodeZeros and ones that settle
- Pro
Erase Text
InteractiveLetters fade under the pointer, then heal
- Pro
Variable Proximity
InteractiveLetters that thicken near the pointer
- Pro
Text Cursor
InteractiveCharacters that trail the pointer
- Pro
Shuffle
DecodeLetters that spin into place