velocity-morph
jolyui-ui/velocity-morphFreeComponent
jolyui/ui publishes no description for this item.
Install it
npx shadcn@latest add https://jolyui.dev/r/velocity-morph.jsonSource
1import { AnimatePresence, motion } from "motion/react";2import * as React from "react";3import { cn } from "@/lib/utils";45interface VelocityMorphProps {6 texts: string[];7 className?: string;8 interval?: number;9}1011const VelocityMorph = React.forwardRef<HTMLDivElement, VelocityMorphProps>(12 ({ texts, className, interval = 3000 }, ref) => {13 const [currentIndex, setCurrentIndex] = React.useState(0);1415 React.useEffect(() => {16 const timer = setInterval(() => {17 setCurrentIndex((prev) => (prev + 1) % texts.length);18 }, interval);1920 return () => clearInterval(timer);21 }, [interval, texts.length]);2223 return (24 <div25 ref={ref}26 className={cn(27 "relative overflow-hidden whitespace-nowrap p-2",28 className,29 )}30 >31 <AnimatePresence mode="popLayout">32 <motion.div33 key={currentIndex}34 initial={{35 y: 40,36 opacity: 0,37 filter: "blur(10px)",38 scale: 0.8,39 }}40 animate={{41 y: 0,42 opacity: 1,43 filter: "blur(0px)",44 scale: 1,45 }}46 exit={{47 y: -40,48 opacity: 0,49 filter: "blur(10px)",50 scale: 0.8,51 }}52 transition={{53 duration: 0.4,54 ease: [0.16, 1, 0.3, 1],55 }}56 >57 {texts[currentIndex]}58 </motion.div>59 </AnimatePresence>60 </div>61 );62 },63);6465VelocityMorph.displayName = "VelocityMorph";6667export { VelocityMorph };
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 |
