Skip to content

Text Morph

text-morph

A short label that morphs into the next in place: shared letters glide, new ones sharpen in, removed ones blur away, and the width follows on a spring so the layout around it never jumps. Letters are split as a reader sees them, so emoji and accents move whole.

Install

$npxshadcnadd@forme/text-morph

Adds the component, its registry dependencies, and the token stylesheet you import once.

Usage

import { TextMorph } from "@/components/forme/text-morph/text-morph";

<Button onClick={publish}>
  <TextMorph>{publishing ? "Publishing" : "Publish"}</TextMorph>
</Button>

When to use

Reach for it

  • A status word or button label that changes a few letters at a time: Publish, Publishing, Published; Follow, Following.

Use something else

  • Sentences or labels that wrap: it stays on one line, and a long morph is motion people wait for.
  • Numbers that tick; NumberFlow rolls digits in place instead.

API reference

Read from the source, so it is the API of the file you install. A prop marked * is required.

TextMorph

Morphs one short label into the next in place.

PropTypeDefaultDescription
children*string—Plain text: a short label. It stays on one line.
as"span" | "div" | "p" | "strong" | "h1" | "h2" | "h3""span"The element to render.

Also takes every prop of Omit<HTMLAttributes<HTMLElement>, "children">.

Accessibility

  • The plain text is in the accessibility tree and the animated letters are hidden from it.
  • Pass aria-live="polite" when the change itself should be announced, as for a save status.

Motion

  • Shared letters glide on spring.snappy; new letters fade, rise and sharpen in over 200ms, 30ms apart and capped at six; leaving letters clear in 150ms on the exit curve.
  • Reduced motion swaps the label and the width on the frame.

Responsive behaviour

  • A web font arriving or a responsive font size resizes the frame directly, without replaying a morph.