Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Text

Pro

Binary Text for React

Text decoded from binary, each character flipping between 0 and 1 before it settles. For React with Base UI, when a headline should feel computed rather than written.

Framework

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.

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 { 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.

Preview width

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.

Preview width

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.

Preview width

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.

What does it show without JavaScript?

With trigger="view", the decoded text, since nothing would start the animation. The other triggers are CSS alone and play as usual.

What happens with reduced motion?

The text shows as it is, with no bits.

API Reference

BinaryText

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

PropType
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.

AttributeType
data-view?string

"in" when visible is true, otherwise "out".

CSS variableType
--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-stepsstring
All 97 text effects