Skip to content
VenusUI
Get started

Scramble Text

Resolves text from random characters, left to right, like a decoder.

Preview

Installation

npx shadcn@latest add @venusui/scramble-text

Run this in a project set up with shadcn. If you haven’t set it up yet, run npx shadcn@latest init first.

Files added to your project

Paths use the default shadcn aliases. The CLI follows the aliases in your components.json.

  • @/components/ui/scramble-text.tsx

Usage

The code behind the preview above.

scramble-text-demo.tsx

import { ScrambleText } from "@/components/ui/scramble-text"

export default function ScrambleTextDemo() {
  return (
    <div className="space-y-3 text-center">
      <ScrambleText as="h2" text="ACCESS GRANTED" className="text-3xl font-semibold tracking-widest" />
      <p className="text-sm text-muted-foreground">
        Hover me: <ScrambleText trigger="hover" text="decrypting…" className="text-foreground" />
      </p>
    </div>
  )
}

API reference

PropTypeDefaultDescription
textstring—The final text. Required.
as"span" | "p" | "h1" | "h2" | "h3""span"Element to render.
trigger"view" | "hover" | "mount""view"Scramble when it enters the viewport, on hover and focus, or once on mount.
durationnumber900Milliseconds until every character has settled.
charactersstring—Characters used while scrambling.
classNamestring—Classes for the element. Uses a monospace font by default so width stays stable.

Only the props above.

Requirements

  • React 19 and Tailwind CSS v4, with a cn helper at @/lib/utils. No other dependencies.

Customization

  • Keep the monospace font, or the text will change width as characters scramble.
  • Use characters="01" for a binary look or "アイウエオカキクケコ" for katakana.

Accessibility

  • Screen readers read the final text from a hidden copy; the scrambling layer is aria-hidden.
  • Nothing scrambles when the user prefers reduced motion.

Troubleshooting

It never scrambles.
With trigger="view" it runs once when 60% of it is visible. Check that it actually scrolls into view, or use trigger="mount".
Unknown registry "@venusui"
Your shadcn CLI couldn’t find the namespace in the shadcn registry index. Use the latest CLI (npx shadcn@latest), install by URL, or register it with its address: npx shadcn@latest registry add @venusui=https://venusui.com/r/{name}.json.
No components.json found
Run npx shadcn@latest init in your project first.
Loading preview

Blur Text

Text animations

Text whose words rise out of a blur one after another.

Loading preview

Gradient Text

Text animations

Text filled with a slowly moving gradient: a subtle sheen by default, or your own colors.

Loading preview

Number Ticker

Text animations

Counts up to a number when it scrolls into view, with locale-aware formatting.