terra vidhal

Morphing Text

Component

About

Text whose letters glide and blur into place whenever the string changes.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Morphing Text to your project and fits it to your theme.

Code

How Morphing Text is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

/**
 * PrequelUI Animate — MIT — https://prequeluianimate.terravidhal.me
 */

import * as React from "react";
import { Sparkles } from "lucide-react";
import { MorphingText } from "@/components/ui/morphing-text";

const WORDS = ["Design", "Animate", "Morph", "Ship"];

export default function MorphingTextDemo() {
  const [value, setValue] = React.useState("");
  const text = value.trim().length > 0 ? value : WORDS;

  return (
    <div className="flex min-h-screen items-center justify-center bg-gradient-to-br from-slate-100 via-white to-slate-200 p-6 dark:from-black dark:via-slate-950 dark:to-slate-900">
      <div className="w-full max-w-2xl rounded-3xl border border-border bg-background/90 p-8 text-center shadow-2xl shadow-slate-900/10 backdrop-blur dark:shadow-black/40">
        <span className="mb-7 inline-flex items-center gap-1.5 rounded-full border border-border bg-muted/40 px-3 py-1.5 text-[11px] font-medium uppercase tracking-[0.28em] text-muted-foreground">
          <Sparkles className="size-3.5" />
          PrequelUI Animate
        </span>

        <div className="flex min-h-[8rem] items-center justify-center">
          <MorphingText
            text={text}
            loop
            holdDelay={1800}
            className="text-5xl font-bold tracking-tight text-foreground sm:text-6xl"
          />
        </div>

        <p className="mx-auto mt-4 max-w-sm text-sm leading-relaxed text-muted-foreground">
          Letters glide to their new positions whenever the string changes.
          Type below to morph the headline.
        </p>

        <label
          htmlFor="morphing-text-input"
          className="mx-auto mt-8 flex max-w-sm flex-col gap-2 text-left"
        >
          <span className="text-xs font-medium uppercase tracking-[0.2em] text-muted-foreground">
            Your text
          </span>
          <input
            id="morphing-text-input"
            data-slot="morphing-text-input"
            type="text"
            value={value}
            onChange={(event) => setValue(event.target.value)}
            placeholder="Try “Hello world”…"
            className="w-full rounded-xl border border-border bg-background px-4 py-2.5 text-sm text-foreground shadow-sm outline-none transition placeholder:text-muted-foreground/60 focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40"
          />
        </label>
      </div>
    </div>
  );
}

Dependencies

More by terra vidhal

View all
  • Image Zoom

    Image Zoom

  • File Drop

    File Drop

  • Sliding Number

    Sliding Number

  • Liquid Button

    Liquid Button

  • Gravity Stars Background

    Gravity Stars Background

Explore more

Part of PrequelUI Animate — browse the full library on 21st.dev.