---
title: "Text Scramble"
description: "Free React text scramble: changed characters cycle through random glyphs before they resolve, while screen readers get the final value. Framer Motion, shadcn."
category: "Components"
parent: "https://beui.dev/components/motion/text-animation"
publishedAt: "2026-05-17"
updatedAt: "2026-11-24"
documentation: "https://beui.dev/components/motion/text-animation/text-scramble"
markdown: "https://beui.dev/components/motion/text-animation/text-scramble.md"
license: "MIT"
---

# Text Scramble

> Free React text scramble: changed characters cycle through random glyphs before they resolve, while screen readers get the final value. Framer Motion, shadcn.

## Install

```bash
npx shadcn@latest add @beui/text-scramble
```

## Dependencies

- `clsx`
- `motion`
- `react`
- `tailwind-merge`

## Usage

### Text Scramble usage

A controlled character scramble that resolves changed text while keeping its final value accessible.

```tsx
"use client";

import { useState } from "react";
import { TextScramble } from "@/components/motion/text-scramble";

const PHRASES = [
  "Inspecting the repository",
  "Running the checks",
  "Preparing the update",
];

export function TextScramblePreview() {
  const [index, setIndex] = useState(0);

  return (
    <div className="flex w-full flex-col items-center gap-8 text-center">
      <TextScramble
        text={PHRASES[index]}
        className="font-mono text-xl font-medium text-foreground"
      />

      <button
        type="button"
        onClick={() => setIndex((current) => (current + 1) % PHRASES.length)}
        className="inline-flex h-9 items-center rounded-full border border-border bg-card px-4 text-xs font-medium text-foreground press hover:border-(--color-border-strong)"
      >
        Next phrase
      </button>
    </div>
  );
}
```

## API Reference

### TextScramble

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `text` | `string` | — | Yes | Final text revealed by the scramble animation. |
| `duration` | `number` | — | No | Maximum animation duration in milliseconds. |
| `glyphs` | `string` | `ABCDEFGHJKLMNPQRSTUVWXYZ0123456789#%&@$?/` | No | Characters sampled while unresolved positions are scrambling. |
| `className` | `string` | — | No | Classes merged onto the root element. |
| `style` | `CSSProperties` | — | No | Inline styles for the root element. |

## More in Text Animation

- [Dia Text Animation](https://beui.dev/components/motion/text-animation/chromatic-reveal.md)
- [Text Reveal](https://beui.dev/components/motion/text-animation/reveal.md)
- [Text Shimmer](https://beui.dev/components/motion/text-animation/shimmer.md)
- [Text Cascade](https://beui.dev/components/motion/text-animation/cascade.md)

## Source

- Registry detail: https://beui.dev/r/text-scramble
- Raw source: https://beui.dev/r/text-scramble/raw
- GitHub: https://github.com/starc007/ui-components
