rotate-text
jolyui-ui/rotate-textFreeComponent
jolyui/ui publishes no description for this item.
Install it
npx shadcn@latest add https://jolyui.dev/r/rotate-text.jsonSource
1import { AnimatePresence, motion } from "motion/react";2import * as React from "react";3import { cn } from "@/lib/utils";45interface RotatingTextProps {6 words: string[];7 className?: string;8 interval?: number;9}1011const RotatingText = React.forwardRef<HTMLSpanElement, RotatingTextProps>(12 ({ words, className, interval = 2000 }, ref) => {13 const [currentIndex, setCurrentIndex] = React.useState(0);1415 React.useEffect(() => {16 const timer = setInterval(() => {17 setCurrentIndex((prev) => (prev + 1) % words.length);18 }, interval);19 return () => clearInterval(timer);20 }, [words.length, interval]);2122 return (23 <span24 ref={ref}25 className={cn("relative inline-flex overflow-hidden", className)}26 >27 <AnimatePresence mode="popLayout">28 <motion.span29 key={currentIndex}30 initial={{ y: "100%", opacity: 0 }}31 animate={{ y: 0, opacity: 1 }}32 exit={{ y: "-100%", opacity: 0 }}33 transition={{34 type: "spring",35 stiffness: 300,36 damping: 30,37 }}38 className="inline-block"39 >40 {words[currentIndex]}41 </motion.span>42 </AnimatePresence>43 </span>44 );45 },46);47RotatingText.displayName = "RotatingText";4849export { RotatingText };
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 |
