# Morphing Text

> React headline that cycles through phrases by blurring one into the next on two stacked layers, pauses off screen and shows the first phrase for reduced motion.

- Kind: Motion component (Motion)
- Docs: https://ui.minidev.pro/docs/morphing-text
- Source (registry JSON with the full file): https://ui.minidev.pro/r/morphing-text.json
- License: MIT. One file, yours to edit after install.

## When to use

Use it for one hero headline that cycles a few phrases. Reach for WordRotate to swap a single word inside a sentence, TypingText for a typewriter, and TextScramble for a one-off decode.

## Installation

### shadcn CLI (copies the source into your project)

```bash
npx shadcn@latest add @minidev/morphing-text
```

Writes `components/ui/morphing-text.tsx` and installs its npm dependencies. Older CLI versions: `npx shadcn@latest add https://ui.minidev.pro/r/morphing-text.json`.

### npm package

```bash
npm i minidev-ui-kit motion
```

Add the tokens to your global stylesheet once:

```css
@import "tailwindcss";
@import "minidev-ui-kit/styles.css";
@source "../node_modules/minidev-ui-kit";
```

Next.js also needs `transpilePackages: ["minidev-ui-kit"]` in next.config.

## Import

After the shadcn install:

```tsx
import { MorphingText } from "@/components/ui/morphing-text"
```

From the npm package:

```tsx
import { MorphingText } from "minidev-ui-kit/premium/morphing-text"
```

## Usage

```tsx
import { MorphingText } from "@/components/ui/morphing-text"

export function Example() {
  return (
    <MorphingText />
  )
}
```

## Props

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `words` | `string[]` | `["Invoices that close themselves", "R...` | no |  |
| `interval` | `number` | `2600` | no | Milliseconds each phrase is held before it melts into the next. |
| `duration` | `number` | `1` | no | Seconds one morph takes. |
| `className` | `string` | - | no |  |

## Examples

### Custom phrases

Pass words in order; the slot reserves the height of the tallest phrase so nothing below it moves.

```tsx
<MorphingText words={["Northwind ships every Friday", "Northwind closes the books in a day", "Northwind never chases an invoice"]} />
```

### Quick cycle

interval is the hold in milliseconds and duration the melt in seconds; short words can go faster than sentences.

```tsx
<MorphingText words={["Fast", "Calm", "Precise", "Yours"]} interval={1400} duration={0.6} className="text-5xl sm:text-6xl" />
```

### Left aligned in a hero

Override the centring and size with className to use the morph as the first line of a left aligned hero.

```tsx
<div className="flex w-full max-w-2xl flex-col items-start gap-5">
  <p className="text-xs font-medium tracking-[0.06em] text-accent-fg uppercase">Lumen for finance teams</p>
  <MorphingText className="mx-0 text-left text-3xl sm:text-4xl" words={["Invoices that close themselves", "Reminders that send themselves", "Books that balance themselves"]} />
  <Button>Start free trial <ArrowRightIcon /></Button>
</div>
```

## Accessibility

- Screen readers get every phrase once, joined with full stops, from an `sr-only` span. The animated layers are `aria-hidden`.
- Under reduced motion it shows the first phrase and never changes.

## FAQ

### Will MorphingText make the layout jump?

No. Every phrase is rendered invisibly in the same grid cell, so the slot is always as tall as the longest phrase at the current width. Content below it never moves.

### Can I use it as an h1?

Not as is. It renders a `<p>`, which cannot sit inside an `<h1>`, so change the tag in the file or keep your `<h1>` separate. Screen readers hear every phrase joined, such as "Invoices that close themselves. Reports that write themselves.", which is long for a page title.

### How do I make the morph slower?

`interval` is how long each phrase holds in milliseconds (default 2600), and `duration` is the length of each morph in seconds (default 1). It pauses when less than 40% is in view.

## Rules for generating code

- Use semantic tokens only (bg, surface, sunken, border, fg, fg-muted, fg-subtle, ink, accent, success, warning, danger). Never raw hex or palette steps like blue-500.
- Shadows only from the set: shadow-xs, shadow-sm, shadow-raised, shadow-md, shadow-lg, shadow-overlay.
- Numbers use tabular-nums. Dark mode is the `dark` class on <html>; components never branch on theme.

## Dependencies

- npm: `motion`

## Related

- [Word Rotate](https://ui.minidev.pro/docs/word-rotate/md): Rotates words inside a sentence: the old word lifts and blurs away as the next rises in. The slot keeps the widest word's width so the line never jumps.
- [Typing Text](https://ui.minidev.pro/docs/typing-text/md): A React typewriter that types a phrase, holds, deletes and moves on, with a blinking accent caret. Starts in view and gives screen readers the plain text.
- [Text Scramble](https://ui.minidev.pro/docs/text-scramble/md): A text effect that scrambles random glyphs and resolves to the final string letter by letter when it scrolls into view. Its aria-label keeps the real text.
- [Animated Feature Row](https://ui.minidev.pro/docs/animated-feature-row/md): A row of feature cards that slide up with a staggered delay when scrolled into view. Pass title and description pairs; reduced motion keeps them still.
- [Card Tilt](https://ui.minidev.pro/docs/card-tilt/md): A card that tilts in 3D toward the pointer on springs, with an accent glare that follows the cursor. It stays flat when reduced motion is preferred.
- [Cursor Spotlight Panel](https://ui.minidev.pro/docs/cursor-spotlight-panel/md): A panel whose accent radial spotlight follows the cursor, driven by Framer Motion values without re-renders. It shows a still surface for reduced motion.

---

All 557 components: https://ui.minidev.pro/llms.txt (full text: https://ui.minidev.pro/llms-full.txt).
