# Text Scramble

> Scramble text through random characters and resolve it left to right, on mount, on view, on hover, or on demand.

Source: https://www.honestui.com/docs/animated/text-scramble

```tsx
"use client";

import { RotateCcw } from "honestui/icons";
import { useState } from "react";

import { TextScramble } from "@/registry/default/animated/text-scramble";

const LINKS = ["Overview", "Deployments", "Analytics", "Settings"];

export function TextScrambleDemo() {
  const [run, setRun] = useState(0);

  return (
    <div className="flex w-full max-w-sm flex-col gap-6">
      <div className="flex items-start justify-between gap-4">
        <div className="flex flex-col gap-1">
          <span className="font-mono text-[11px] uppercase tracking-[0.14em] text-muted-foreground">
            <TextScramble replayKey={run} duration={0.6}>
              Build 2026.11.26
            </TextScramble>
          </span>
          <TextScramble
            as="h3"
            replayKey={run}
            duration={1.1}
            className="text-2xl font-semibold tracking-tight text-foreground"
          >
            Deployment complete
          </TextScramble>
        </div>
        <button
          type="button"
          onClick={() => setRun((count) => count + 1)}
          className="inline-flex h-7 shrink-0 items-center gap-1 rounded-md border border-border px-2 text-xs font-medium text-foreground transition-colors hover:bg-muted"
        >
          <RotateCcw className="size-3.5" />
          Replay
        </button>
      </div>
      <nav aria-label="Project" className="flex flex-wrap gap-x-5 gap-y-2 border-t border-border pt-4">
        {LINKS.map((link) => (
          <a
            key={link}
            href={`#${link.toLowerCase()}`}
            className="font-mono text-[13px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground"
          >
            <TextScramble trigger="hover" duration={0.45} characters="01#/<>_=">
              {link}
            </TextScramble>
          </a>
        ))}
      </nav>
    </div>
  );
}

```

## Overview [#overview]

Text Scramble cycles each character through random glyphs and settles them in reading order, the "decoding" effect used for status changes, build labels, and terminal-style navigation. Use it for short labels whose change is worth noticing. Avoid it on body text, where a reader would have to wait to read.

Every scrambling glyph is drawn over an invisible copy of its final character, so a random wide glyph such as `W` never pushes the line wider. The only change during a scramble is a pixel or two of lost kerning between characters, and settled text keeps its normal kerning. For a perfectly fixed width, use a monospaced font, which has no kerning. Spaces stay in place by default, so words keep their shape and long text still wraps between them.

## Installation [#installation]

<CliBlock commands="[&#x22;text-scramble&#x22;]" />

## Usage [#usage]

```tsx
import { TextScramble } from "@/components/animated/text-scramble"

<TextScramble>Deployment complete</TextScramble>
```

Play it on hover or keyboard focus, for navigation links:

```tsx
<a href="/settings">
  <TextScramble trigger="hover" characters="01#/<>_=">
    Settings
  </TextScramble>
</a>
```

Change `children` or `replayKey` to play it again, for example after a status update or a button press.

## Accessibility [#accessibility]

Assistive technology reads the final text from a visually hidden copy, and the scrambling characters are hidden from it. Screen readers never hear the random characters. The server and the first client render both show the final text, so the content is readable before JavaScript runs.

With reduced motion enabled, the text changes to its final value at once without scrambling.

## API Reference [#api-reference]


  ### `children`

type: `string`

Final text. Changing it scrambles into the new value.

  ### `as`

type: `ElementType` · default: `&#x22;span&#x22;`

Element to render.

  ### `trigger`

type: `&#x22;mount&#x22; | &#x22;view&#x22; | &#x22;hover&#x22;` · default: `&#x22;mount&#x22;`

When the scramble plays. 

    `hover`

     also plays on keyboard focus.

  ### `replayKey`

type: `unknown`

Plays the scramble again whenever this value changes.

  ### `duration`

type: `number` · default: `0.8`

Seconds until the last character resolves.

  ### `speed`

type: `number` · default: `40`

Milliseconds between random-character swaps.

  ### `characters`

type: `string` · default: `A–Z, a–z, 0–9`

Characters drawn while scrambling.

  ### `scrambleSpaces`

type: `boolean` · default: `false`

Scrambles spaces too, hiding word gaps during the effect.

  ### `onComplete`



void">
    Called once the text has resolved.

  ### `className`

type: `string`

Class for the root element.

  ### `scrambleClassName`

type: `string`

Class for characters that are still scrambling, such as a muted color.
