Dynamic Text
kokonut-ui/dynamic-textFreeComponent
Dynamic switcher text.
Live preview
live · rendered by the registry
Rendered by kokonut-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://kokonutui.com/r/dynamic-text.jsonSource
1"use client";23/**4 * @author: @dorianbaffier5 * @description: Dynamic Text6 * @version: 1.0.07 * @date: 2025-06-268 * @license: MIT9 * @website: https://kokonutui.com10 * @github: https://github.com/kokonut-labs/kokonutui11 */1213import { AnimatePresence, motion } from "motion/react";14import { useEffect, useState } from "react";1516interface Greeting {17 text: string;18 language: string;19}2021const greetings: Greeting[] = [22 { text: "Hello", language: "English" },23 { text: "こんにちは", language: "Japanese" },24 { text: "Bonjour", language: "French" },25 { text: "Hola", language: "Spanish" },26 { text: "안녕하세요", language: "Korean" },27 { text: "Ciao", language: "Italian" },28 { text: "Hallo", language: "German" },29 { text: "こんにちは", language: "Japanese" },30];3132const DynamicText = () => {33 const [currentIndex, setCurrentIndex] = useState(0);34 const [isAnimating, setIsAnimating] = useState(true);3536 useEffect(() => {37 if (!isAnimating) return;3839 const interval = setInterval(() => {40 setCurrentIndex((prevIndex) => {41 const nextIndex = prevIndex + 1;4243 if (nextIndex >= greetings.length) {44 clearInterval(interval);45 setIsAnimating(false);46 return prevIndex;47 }4849 return nextIndex;50 });51 }, 300);5253 return () => clearInterval(interval);54 }, [isAnimating]);5556 // Animation variants for the text57 const textVariants = {58 hidden: { y: 20, opacity: 0 },59 visible: { y: 0, opacity: 1 },60 exit: { y: -100, opacity: 0 },61 };6263 return (64 <section65 aria-label="Rapid greetings in different languages"66 className="flex min-h-[200px] items-center justify-center gap-1 p-4"67 >68 <div className="relative flex h-16 w-60 items-center justify-center overflow-visible">69 {isAnimating ? (70 <AnimatePresence mode="popLayout">71 <motion.div72 animate={textVariants.visible}73 aria-live="off"74 className="absolute flex items-center gap-2 font-medium text-2xl text-gray-800 dark:text-gray-200"75 exit={textVariants.exit}76 initial={textVariants.hidden}77 key={currentIndex}78 transition={{ duration: 0.2, ease: "easeOut" }}79 >80 <div81 aria-hidden="true"82 className="h-2 w-2 rounded-full bg-black dark:bg-white"83 />84 {greetings[currentIndex].text}85 </motion.div>86// … truncated
What it pulls in
npm packages
Files it writes
More from kokonut-ui
All 40 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Action Search Baraction-search-bar | kokonut-ui | Components | Free | 2 deps · 2 files | |
| AI Input Searchai-input-search | kokonut-ui | Components | Free | 1 dep · 2 files | |
| AI State Loadingai-loading | kokonut-ui | Components | Free | 1 dep | |
| AI Input Selectorai-prompt | kokonut-ui | Components | Free | 2 deps · 4 files | |
| AI Text Loadingai-text-loading | kokonut-ui | Components | Free | 1 dep | |
| AI Voiceai-voice | kokonut-ui | Components | Free | 2 deps | |
| Apple Activity Cardapple-activity-card | kokonut-ui | Components | Free | 1 dep | |
| Magnet Buttonattract-button | kokonut-ui | Components | Free | 2 deps |
