Cnippet

Text Morph

Text 1

About

Shared-layout character morphing between two strings — individual letters animate to their new positions with spring physics.

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

Code

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

Usage.tsx

"use client";

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

const suggestions = ["Search docs", "Search components", "Search examples"];

export default function TextMorphSearch() {
  const [query, setQuery] = useState("");
  const placeholder =
    suggestions[query.length % suggestions.length] ?? suggestions[0];

  return (
    <div className="flex min-h-50 flex-col items-center justify-center gap-4 px-6">
      <div className="relative w-full max-w-md">
        <div className="pointer-events-none absolute inset-y-0 left-3.5 flex items-center text-muted-foreground">
          <svg
            className="h-4 w-4"
            fill="none"
            stroke="currentColor"
            strokeWidth={2}
            viewBox="0 0 24 24"
          >
            <circle cx="11" cy="11" r="8" />
            <path d="m21 21-4.35-4.35" />
          </svg>
        </div>
        <input
          className="h-10 w-full rounded-lg border border-border bg-background pr-4 pl-9 text-foreground text-sm outline-none placeholder:text-transparent focus:ring-2 focus:ring-ring"
          onChange={(e) => setQuery(e.target.value)}
          type="text"
          value={query}
        />
        {!query && (
          <div className="pointer-events-none absolute inset-y-0 left-9 flex items-center">
            <TextMorph className="text-muted-foreground text-sm">
              {placeholder ?? ""}
            </TextMorph>
          </div>
        )}
      </div>
      <p className="text-muted-foreground text-xs">
        Placeholder morphs as you type
      </p>
    </div>
  );
}

Dependencies

More by Cnippet

View all
  • Team

    Team

    1.3K
  • Davincho Hero-1

    Davincho Hero-1

    683
  • Aero Hero-3

    Aero Hero-3

    558
  • Features

    Features

    510
  • Random Letter Swap Navigation

    Random Letter Swap Navigation

    487
  • Services with Animated Hover Modal

    Services with Animated Hover Modal

    465
  • Blogs

    Blogs

    396
  • Aero Hero-1

    Aero Hero-1

    356

More in Text

View all
  • Motion Blur Text

    Motion Blur Text

    36
  • Vertical Cut Reveal Characters

    Vertical Cut Reveal Characters

    103
  • NeonRGBTextEffect

    NeonRGBTextEffect

    144
  • Text Reveal

    Text Reveal

    27
  • Random Letter Swap

    Random Letter Swap

    46
  • Rainbow Text Effect

    Rainbow Text Effect

    47
  • Text Color

    Text Color

    545
  • Blur Reveal

    Blur Reveal

    300