---
title: "Text Scramble"
description: "The letters change to random characters, then settle one by one into the real text, like a decoder."
url: https://gelatinui.com/components/text-scramble
markdown_url: https://gelatinui.com/components/text-scramble.md
access: free
install: "npx shadcn@latest add @gelatin-ui/text-scramble"
registry_item: https://gelatinui.com/r/text-scramble.json
version: "2026-11-14"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Text Scramble

> The letters change to random characters, then settle one by one into the real text, like a decoder.

Page: https://gelatinui.com/components/text-scramble

## When to use it

Best for: A short heading, label, or link that decodes into place once, or each time the pointer comes.

- Use `trigger="hover"` inside a link or a button: the control starts it on hover and on keyboard focus.
- Use a monospace font when the text must not shake: every letter has one width.
- Use `characters` for your own set (`"01"`, block marks); the default keeps each letter's kind and about its width.
- Change the text to scramble the new one into place (a status that moves to the next step).

## When not to use it

- For a board of letters that flip one card at a time, use [Text Split Flap](https://gelatinui.com/components/text-split-flap.md).

## Notes for agents

- `children` must be a string. A new text, `characters`, `order`, or `locale` scrambles again.
- The real word stays in the page under the shown one, transparent: copy and screen readers get the real text.
- With `view` and `mount` the text is scrambled from the first paint (the server HTML too) until its run settles it; with `hover` it is the real text until the pointer comes.
- The default time is 40ms a letter, from 0.5s to 1.2s; `duration` sets it in seconds.
- A wider random letter can overlap the next word by a few pixels, but a word never moves to another line.
- Emoji and punctuation stay; other scripts scramble with the letters of the text itself.

## Anatomy

```text
TextScramble
```

## API reference

### TextScramble

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `locale` | `string` |  | The BCP 47 locale for the letter and word split (`Intl.Segmenter`). Default: the `DisplayLocaleProvider` locale, else `"en-US"`. |
| `children` | `string` |  | The text. A new text scrambles into place again. |
| `trigger` | `"hover" \| "mount" \| "view"` | "view" | When the scramble runs: `view` (default) the first time it is on screen, `mount` at once, or `hover` each time the pointer enters it or keyboard focus reaches it. With `hover` inside a link or a button, that control starts it. With `view` and `mount` the text is scrambled from the first paint (the server HTML too) until its run decodes it; with `hover` it is the real text until the pointer comes. |
| `duration` | `number` |  | Seconds from start to the last letter in place. Default: 40ms a letter, 0.5s to 1.2s. |
| `characters` | `string` |  | The letters to scramble with. Default: a random letter of the same kind and about the same width (a narrow small letter becomes another narrow one; a digit becomes a digit), and the letters of the text itself for scripts other than Latin, so a word keeps about its width. |
| `order` | `"center" \| "edges" \| "end" \| "random" \| "start"` | "start" | The order in which the letters settle: `start` (default, reading order), `end`, `center` (from the middle out), `edges` (from both ends in), or `random` (a fixed shuffle of each text). |
| `punctuation` | `"keep" \| "scramble"` | "keep" | What happens to marks that are not letters or digits ("$", ",", "•"): `keep` (default) leaves them in place, `scramble` changes them with the letters, so a row of dots can scramble from digits or back. |
| `onComplete` | `function` |  | Called when the last letter is in place. |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| TextScramble | `text-scramble` |  |  |  |

## Usage

Wrap a heading, or the label of a link or a button with `trigger="hover"`.

```tsx title="studio-nav.tsx"
import { TextScramble } from "@/components/text/text-scramble";

const LINKS = ["Work", "Studio", "Journal", "Contact"];

export function StudioNav() {
  return (
    <header className="flex flex-col gap-6">
      <h1 className="font-mono text-4xl font-semibold">
        <TextScramble trigger="mount">SIGNAL ACQUIRED</TextScramble>
      </h1>
      <nav aria-label="Main" className="flex gap-6 font-mono text-sm uppercase">
        {LINKS.map((link) => (
          <a
            key={link}
            href={`#${link.toLowerCase()}`}
            className="text-muted-foreground hover:text-foreground"
          >
            <TextScramble trigger="hover">{link}</TextScramble>
          </a>
        ))}
      </nav>
    </header>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/text-scramble
```

It adds 24 registry items: 23 files, 3927 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `@xstate/react`, `clsx`, `motion`, `tailwind-merge`, `xstate`.

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Text Typewriter](https://gelatinui.com/components/text-typewriter.md)
- [Text Redact Reveal](https://gelatinui.com/components/text-redact-reveal.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Tab | With `trigger="hover"`, keyboard focus on the link or button around the text starts the scramble. |

## Motion

| Part | Motion |
| --- | --- |
| Scramble | progress · 40ms a letter, 0.5s to 1.2s · linear · every letter changes 20 times a second for the first quarter, then the letters settle in `order` |
| Restart | progress · a new hover in the middle of a run starts it again from the top |
