character-morph
jolyui-ui/character-morphFreeComponent
jolyui/ui publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by jolyui/ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://jolyui.dev/r/character-morph.jsonSource
1import { AnimatePresence, motion } from "motion/react";2import * as React from "react";3import { cn } from "@/lib/utils";45interface CharacterMorphProps {6 texts: string[];7 className?: string;8 interval?: number;9 staggerDelay?: number;10 charDuration?: number;11}1213const CharacterMorph = React.forwardRef<HTMLDivElement, CharacterMorphProps>(14 (15 {16 texts,17 className,18 interval = 3000,19 staggerDelay = 0.03,20 charDuration = 0.5,21 },22 ref,23 ) => {24 const [currentIndex, setCurrentIndex] = React.useState(0);25 const currentText = texts[currentIndex] || "";2627 React.useEffect(() => {28 const timer = setInterval(() => {29 setCurrentIndex((prev) => (prev + 1) % texts.length);30 }, interval);3132 return () => clearInterval(timer);33 }, [interval, texts.length]);3435 const maxLength = Math.max(...texts.map((t) => t.length));3637 return (38 <div39 ref={ref}40 className={cn("relative inline-flex whitespace-nowrap", className)}41 >42 <AnimatePresence mode="popLayout">43 {currentText.split("").map((char, i) => (44 <motion.span45 key={`${currentIndex}-${i}-${char}`}46 initial={{ opacity: 0, y: 20, filter: "blur(8px)", rotateX: -90 }}47 animate={{ opacity: 1, y: 0, filter: "blur(0px)", rotateX: 0 }}48 exit={{ opacity: 0, y: -20, filter: "blur(8px)", rotateX: 90 }}49 transition={{50 duration: charDuration,51 delay: i * staggerDelay,52 ease: [0.215, 0.61, 0.355, 1],53 }}54 className="inline-block"55 style={{ transformStyle: "preserve-3d" }}56 >57 {char === " " ? "\u00A0" : char}58 </motion.span>59 ))}60 </AnimatePresence>61 {/* Maintain minimum width */}62 <span className="invisible absolute">{"M".repeat(maxLength)}</span>63 </div>64 );65 },66);6768CharacterMorph.displayName = "CharacterMorph";69export { CharacterMorph };
What it pulls in
npm packages
Files it writes
More from jolyui/ui
All 199 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| ai-prompt-boxai-prompt-box | jolyui/ui | Components | Free | 4 deps | |
| animated-beamanimated-beam | jolyui/ui | Components | Free | 1 dep | |
| animated-tableanimated-table | jolyui/ui | Components | Free | 2 deps | |
| animated-theme-toggleanimated-theme-toggle | jolyui/ui | Components | Free | 2 deps | |
| animated-toastanimated-toast | jolyui/ui | Components | Free | 2 deps | |
| animated-tooltipanimated-tooltip | jolyui/ui | Components | Free | 1 dep | |
| bento-gridbento-grid | jolyui/ui | Components | Free | no deps | |
| buttonbutton | jolyui/ui | Components | Free | 3 deps |
