Morphing Text

Letters glide to their new positions when the string changes.

morphing-text.tsx

Installation

1

Install the packages

npm install @prequelui/react motion

@prequelui/react reuses the primitive library your components already depend on.

2

Add the component

npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/morphing-text.json

npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/morphing-text.json

3

Turn on the motion

npx @prequelui/cli@latest animate morphing-text

The CLI finds the component through components.json, swaps the import and removes the CSS animation classes that Motion replaces.

Usage

Import the component and compose it exactly like the primitive it wraps. Motion is enabled by default; the tempo prop scales every duration and softens every spring.

morphing-text.tsx
import { MorphingText } from "@/components/prequelui/morphing-text";

export default function Demo() {
  return (
    <MorphingText
      text={["motion", "design", "product", "rhythm"]}
      holdDelay={2500}
      loop
      className="text-4xl font-medium"
    />
  );
}
import { MorphingText } from "@/components/prequelui/morphing-text";

export function Variant() {
  return (
    <MorphingText tempo={1.2}>
      …
    </MorphingText>
  );
}

Animation

Letters are matched between the two strings, so shared letters stay put while the others leave and enter. Each incoming letter starts eighty milliseconds after the change and twelve milliseconds after the previous one; layout animation carries every survivor to its new position.

  • Surviving letters animate with a 300/30 position spring.
  • New letters enter from 0.12 em below with a 6 px blur.
  • Departing letters leave with a 150 ms blur and fade.
  • The cycle pauses off-screen and the final text is announced once.
spring 300 / 30delay 80 msstagger 12 msblur 6 px

API Reference

Each part accepts the usual HTML props in addition to the motion props below. No accessibility prop is hidden behind the animation layer.

MorphingText

PropTypeDefault
textstring | string[]—
delaynumber0
holdDelaynumber2500
loopbooleanfalse
inViewbooleanfalse

Built by Vidhal. The source is available on GitHub.

Last updated: 11/17/2026