MCPcopy Create free account
hub / github.com/SyntaxUI/syntaxui / TextFlip

Function TextFlip

src/showcase/components/text/TextFlip.tsx:8–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6const text = ['Syntax UI', 'UI Library', 'Text Flip']
7
8const TextFlip = () => {
9 const [index, setIndex] = useState(0)
10
11 useEffect(() => {
12 const id = setInterval(() => {
13 setIndex((state) => {
14 if (state >= text.length - 1) return 0
15 return state + 1
16 })
17 }, 2000)
18 return () => clearInterval(id)
19 }, [])
20
21 return (
22 <div className="relative flex w-full items-center justify-center py-4 text-center">
23 <AnimatePresence mode="wait">
24 <motion.div
25 className="absolute cursor-pointer text-3xl font-semibold tracking-tight text-red-500"
26 key={index}
27 initial={{ rotateX: 90, opacity: 0 }}
28 animate={{ rotateX: 0, opacity: 1 }}
29 exit={{ rotateX: -90, opacity: 0 }}
30 transition={{ duration: 0.2 }}
31 >
32 {text[index]}
33 </motion.div>
34 </AnimatePresence>
35 </div>
36 )
37}
38
39export default TextFlip

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected