# Encrypt Text

> Letters scramble through a pool of random characters before settling on the target text, one character at a time.

Source: https://nyxui.com/components/encrypt-text

---
<ComponentPreview name="encrypt-text-demo" />

Encrypt Text is a React text effect that scrambles each character through a pool of random glyphs — letters, digits, symbols — before settling on the target string. Settling fans out left-to-right so the final text reveals itself progressively, and whitespace is held constant so word shapes stay legible while surrounding letters are still scrambling.

Trigger it on mount, on hover, the first time it scrolls into view, or manually.

## Installation

<Tabs defaultValue="cli">

<TabsList>
  <TabsTrigger value="cli">CLI</TabsTrigger>
  <TabsTrigger value="manual">Manual</TabsTrigger>
</TabsList>

<TabsContent value="cli">

```bash
npx shadcn@latest add "https://nyxui.com/r/encrypt-text.json"
```

</TabsContent>

<TabsContent value="manual">

<Steps>

<Step>Copy and paste the following code into your project.</Step>

<ComponentSource name="encrypt-text" />

<Step>Update the import paths to match your project setup.</Step>

</Steps>

</TabsContent>

</Tabs>

## Usage

```tsx
import { EncryptText } from "@/components/ui/encrypt-text";

export function Example() {
  return <EncryptText text="DESIGN SHARP · SHIP FAST" />;
}
```

### Hover to replay

```tsx
<EncryptText text="hover me" trigger="hover" />
```

### Reveal on scroll into view

```tsx
<EncryptText text="sliding into view…" trigger="inView" />
```

### Custom character pool

```tsx
<EncryptText text="HELLO" chars="01" tickMs={40} />
// → scrambles through 0s and 1s only
```

### Play manually from a ref

```tsx
const ref = useRef<EncryptTextHandle>(null);

<EncryptText ref={ref} text="ACCESS GRANTED" trigger="manual" />
<button onClick={() => ref.current?.play()}>Decrypt</button>
```

## Props

| Prop                | Type                                         | Default                    | Description                                        |
| ------------------- | -------------------------------------------- | -------------------------- | -------------------------------------------------- |
| `text`              | `string`                                     | —                          | The final text to settle on.                       |
| `chars`             | `string`                                     | letters + digits + symbols | Pool of characters to sample while scrambling.     |
| `tickMs`            | `number`                                     | `55`                       | Milliseconds between scramble frames.              |
| `revealSeconds`     | `number`                                     | `0.9`                      | Total seconds over which the full reveal fans out. |
| `trigger`           | `"mount" \| "hover" \| "inView" \| "manual"` | `"mount"`                  | When to play the scramble.                         |
| `startDelay`        | `number`                                     | `0`                        | Delay in ms before the first play.                 |
| `as`                | `ElementType`                                | `"span"`                   | Element to render.                                 |
| `className`         | `string`                                     | —                          | Extra classes.                                     |
| `scrambleClassName` | `string`                                     | `"opacity-40"`             | Classes for characters still scrambling.           |