---
title: "Text Morph"
description: "Text that morphs between strings: shared letters glide into place while new ones spring up one by one and old ones drop away. For button states."
category: "Micro Interactions"
publishedAt: "2026-11-16"
updatedAt: "2026-11-16"
documentation: "https://beui.dev/micro-interactions/text-morph"
markdown: "https://beui.dev/micro-interactions/text-morph.md"
license: "MIT"
---

# Text Morph

> Text that morphs between strings: shared letters glide into place while new ones spring up one by one and old ones drop away. For button states.

## Install

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

## Dependencies

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

## Usage

```tsx
"use client";

import { useState } from "react";
import { TextMorph } from "@/components/motion/text-morph";

export function TextMorphUsage() {
  const [saved, setSaved] = useState(false);

  return (
    <button type="button" onClick={() => setSaved((value) => !value)} className="text-sm font-medium">
      <TextMorph>{saved ? "Saved" : "Save changes"}</TextMorph>
    </button>
  );
}
```

## API Reference

### TextMorph

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `children` | `string` | — | Yes | The text to show. Changing it morphs from the previous string. |
| `className` | `string` | — | No | Classes merged onto the root element. |

## About Text Morph

Text Morph is a React text animation built with Framer Motion that morphs one string into another. Letters the two strings share, paired by their longest common subsequence, glide on a spring from where they are drawn to their new place. New letters spring up into place one at a time, left to right, and letters that leave drop away one by one from the end while riding along with their nearest neighbour that stays. The box springs to the new width. Subscribe, Subscribing and Subscribed read as one word changing rather than three labels swapping, and a change mid-morph retargets every spring from where it is.

### When to use it

- A button label moves through states, such as Subscribe, Subscribing and Subscribed.
- A toggle names its state in words, such as Show more and Show less.
- A heading or tab title changes in place and should feel continuous.

### Accessibility

The full string sits in screen reader text while the animated letters are hidden from assistive technology, so the label is always read whole. With reduced motion the letters crossfade in place: nothing slides or scales.

### FAQ

**How are shared letters matched?**

By their longest common subsequence: the longest run of characters, in order, that both strings contain stays and slides; everything else leaves or arrives. Matching is case sensitive.

**Can I use it outside a button?**

Yes. It renders an inline span that takes your className, so it fits any text: headings, tabs, badges or labels.

## Source

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