shadcn.io is not affiliated with official shadcn/ui
Binary Text starts every character as a bit, a muted 0 or 1 in a monospaced digit, flipping fast, then settles each one on its real character, one after another, so a wave of bits collapses into words. It plays once, when the text scrolls into view; it can also play as soon as the page shows it, or every time the pointer comes over it.
Use it for a developer tool's hero, a security page, or any decoding moment that should feel computational rather than chaotic. For letters and symbols instead of bits, use Decrypted Text; to scramble the characters under the pointer, Scrambled Text. There's no timer and nothing random: every character is a window over a column of bits ending in itself, stepped through by a CSS keyframe animation the install adds to your stylesheet, so the server and the browser draw the same bits. With reduced motion the text is plain.
Installation
Usage
import { BinaryText } from "@/components/ui/binary-text";<BinaryText text="Hello, world" />Demos
Hover
trigger="hover" decodes the text each time the pointer comes over it, and shows it plain the rest of the time. A monospaced font, as here, gives every character the width of a bit, so no bit is ever clipped.
Timing
steps is how many bits each character flips through, speed how long each bit shows, and stagger the time between one character settling and the next; stagger={0} settles them all at once. trigger="mount" plays it as soon as the page shows it.
Bit colour
bitColor is the colour of the bits, any CSS colour or theme variable; by default they're the text's own colour at 45%, so the real characters stand out as they land.
Accessibility
Screen readers read the real text once, from a visually hidden copy, never the bits. Every character keeps its own width while it decodes, so the line never shifts. With reduced motion the text shows as it is.
FAQ
How is it different from Decrypted Text?
Decrypted Text scrambles through letters and symbols in the text's own style. Binary Text only ever shows 0 and 1, monospaced and muted, and its bits flip on almost every step, so it reads as data being decoded rather than noise settling.
Are the bits random?
They look it but aren't: each bit comes from a small formula of the character's place and the step, which flips the last bit three times in four, so the server and the browser draw the same bits and the page never mismatches.
Why doesn't the line jump while it decodes?
Each character is a window as wide as itself, with its bits in a column behind it. In a proportional font, a bit wider than a narrow letter, such as an i, is clipped to the letter's width; in a monospaced font, such as font-mono, every bit shows whole.
When does it play?
With trigger="view", the default, once, when a quarter of the text is in view. trigger="mount" plays it as soon as the page shows it, and trigger="hover" every time the pointer comes over it; on a touch screen, where there's no hover, the text shows plain.
API Reference
BinaryText
<span> data-slot="binary-text"
textstring
The text.
bitColor?string
The colour of the bits before each character settles, any CSS colour.
- Default
"color-mix(in oklab, currentColor 45%, transparent)"
speed?number
How long each bit shows before the next, in milliseconds. @default 50.
stagger?number
The time between one character settling and the next, in milliseconds;
0 settles them all at once.
- Default
80
steps?number
How many bits each character flips through before it settles. @default 8.
- Default
8
trigger?"view" | "mount" | "hover"
What plays it: the text scrolling into view, the page showing it, or the pointer over the text (again on every hover).
- Type
"view" | "mount" | "hover"- Default
"view"
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.
data-view?string
"in" when visible is true, otherwise "out".
--binary-text-bit-colorstring
The colour of the bits (currentColor at 45%).
--binary-text-speedstring
How long each bit shows (50ms).
--binary-text-staggerstring
The time between one character settling and the next (80ms).
--binary-text-stepsstringRelated
- Pro
Decrypted Text
DecodeLetters and symbols instead of bits
- Pro
Scrambled Text
DecodeScramble the letters under the pointer
- Pro
Shuffle
DecodeLetters that spin through a reel
- Pro
Glitch Text
DecorativeNoise that tears and never settles
- Pro
Dot Matrix Text
DecorativeText lit on a grid of dots
- Pro
Terminal Text
EntranceA command line for the same page