Text Morph
forgeui/text-morphFreeComponent
A React component that animates rotating text characters using Motion, customizable by words, interval, styling, and animation timing.
Live preview
live · rendered by the registry
Rendered by ForgeUI on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://forgeui.in/r/text-morph.jsonSource
1"use client";23import { useEffect, useMemo, useState } from "react";4import { AnimatePresence, motion } from "motion/react";56type TextMorphProps = {7 words?: string[];8 interval?: number;9 className?: string;10 charClassName?: string;11};1213const defaultWords = ["engineer", "developer", "designer"];1415export function TextMorph({16 words = defaultWords,17 interval = 2500,18 className,19 charClassName,20}: TextMorphProps) {21 const [index, setIndex] = useState(0);2223 useEffect(() => {24 if (!words.length) return;2526 const timer = setInterval(() => {27 setIndex((prev) => (prev + 1) % words.length);28 }, interval);2930 return () => clearInterval(timer);31 }, [words, interval]);3233 const chars = useMemo(() => {34 return Array.from(words[index] ?? "");35 }, [index, words]);3637 if (!words.length) return null;3839 return (40 <AnimatePresence mode="popLayout">41 <motion.span42 key={index}43 className={`flex gap-[0.5px] overflow-hidden ${className ?? ""}`}44 initial={{ opacity: 0, y: 5 }}45 animate={{ opacity: 1, y: 0 }}46 exit={{ opacity: 0, y: -5 }}47 transition={{ duration: 0.4 }}48 >49 {chars.map((char, i) => (50 <motion.span51 key={i}52 className={charClassName}53 initial={{ opacity: 0, y: 5, filter: "blur(5px)" }}54 animate={{ opacity: 1, y: 0, filter: "blur(0px)" }}55 exit={{ opacity: 0, y: -5, filter: "blur(5px)" }}56 transition={{57 delay: i * 0.03,58 duration: 0.3,59 }}60 >61 {char}62 </motion.span>63 ))}64 </motion.span>65 </AnimatePresence>66 );67}
Files it writes
More from ForgeUI
All 28 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Formanimated-form | ForgeUI | Components | Free | no deps | |
| Animated OTPanimated-otp | ForgeUI | Components | Free | no deps | |
| Animated Tabsanimated-tabs | ForgeUI | Components | Free | no deps | |
| Auralisauralis | ForgeUI | Components | Free | no deps | |
| Bot Detectionbot-detection | ForgeUI | Components | Free | no deps | |
| Chromatic Fluidchromatic-fluid | ForgeUI | Components | Free | no deps | |
| Cloudscapecloudscape | ForgeUI | Components | Free | no deps | |
| Cosmicriftcosmicrift | ForgeUI | Components | Free | no deps |
