Animations/Morphing Text

Morphing Text

Texte qui morphe entre differents mots avec cross-fade blur. Transition fluide.

autoCSStexttransitionhero
Trigger: Automatique (boucle)
CSS requis: Non
Difficulte: easy

Preview live

Code

"use client";
import { useState, useEffect } from "react";

const words = ["Innovation", "Creativity", "Excellence", "Design"];

export default function MorphingText() {
  const [index, setIndex] = useState(0);
  const [phase, setPhase] = useState<"visible" | "morphing">("visible");

  useEffect(() => {
    const timer = setInterval(() => {
      setPhase("morphing");
      setTimeout(() => {
        setIndex((i) => (i + 1) % words.length);
        setPhase("visible");
      }, 500);
    }, 3000);
    return () => clearInterval(timer);
  }, []);

  return (
    <span style={{
      filter: phase === "morphing" ? "blur(8px)" : "blur(0px)",
      opacity: phase === "morphing" ? 0 : 1,
      transition: "filter 0.5s, opacity 0.5s",
    }}>
      {words[index]}
    </span>
  );
}

Instructions

Cross-fade blur entre les mots. Le blur (8px) + opacity 0 cree l'effet de morphing. Ajustez l'intervalle (3000ms), la duree du morph (500ms) et l'intensite du blur.