# Dynamic Text

Morphing text where shared letters travel, old ones fall and new ones land, with decode and cycle modes.

Install with

```bash
npx shadcn@latest add https://kokonutui.com/r/dynamic-text.json
```

## Installation

Dynamic Text is a free, open-source React component in the Kokonut UI [Texts collection](/content/docs/texts/index.html). Add it with the shadcn CLI, which copies the source into `components/kokonutui/dynamic-text.tsx`, so the code is yours to change.

```bash
npx shadcn@latest add @kokonutui/dynamic-text
```

## Usage

```javascript
import DynamicText from "@/components/kokonutui/dynamic-text";

export default function Example() {
  return <DynamicText />;
}
```

## Props

### `mode`

- `DynamicTextMode` Default: "morph"
- `morph`: letters travel, fall and land. 
- `decode`: monospace cells scramble and lock left to right. 
- `cycle`: morphs through `words` with a greeting rhythm (a long first word, faster middle words, a hold on the last).

### `text`

- `string`  
  The string to show. Change it to animate. When set, `words` is ignored.

### `words`

- `(string | Greeting)[]`  
  Words to rotate through when `text` is not set.

### `interval`

- `number`  
  Milliseconds each word holds. In `cycle` mode this is the first word's hold; the middle words speed up from there.

### `loop`

- `boolean`  
  Start over after the last word. Defaults to true, except in `cycle`.

### `onComplete`

- `() => void`  
  Called once the last word is shown. Never called when looping.

### `className`

- `string`  
  Extra classes for the root element.

### DynamicTextMode

```typescript
type DynamicTextMode = "morph" | "decode" | "cycle";
```

### Greeting

- `text` required
- `string`  
- `lang`  
  BCP 47 language tag, so screen readers pronounce each word correctly.

## Dependencies

| Needs | Version | Comes from |
| --- | --- | --- |
| `cn` from `lib/utils.ts` |  | shadcn init |
| React | `19` | Your app |
| Tailwind CSS | `4` | Your app |

No provider, font or global CSS to set up: the file works as soon as it lands.
