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

Function CopyPasteButton

src/showcase/playground/CopyPasteButton.tsx:7–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5import React, { useEffect, useState } from 'react'
6
7const CopyPasteButton = () => {
8 const [copied, setCopied] = useState(false)
9 const variants = {
10 hidden: { opacity: 0, scale: 0.5 },
11 visible: { opacity: 1, scale: 1 },
12 }
13
14 useEffect(() => {
15 if (copied) {
16 setTimeout(() => {
17 setCopied(false)
18 }, 1000)
19 }
20 }, [copied])
21
22 return (
23 <motion.button
24 whileTap={{ scale: 0.9, opacity: 0.8 }}
25 onClick={() => setCopied(!copied)}
26 className="rounded-lg border border-gray-100 bg-red-500 p-3 text-white"
27 >
28 <AnimatePresence mode="wait" initial={false}>
29 {copied ? (
30 <motion.span
31 key="checkmark"
32 variants={variants}
33 initial="hidden"
34 animate="visible"
35 exit="hidden"
36 >
37 <Check size={16} />
38 </motion.span>
39 ) : (
40 <motion.span
41 key="copy"
42 variants={variants}
43 initial="hidden"
44 animate="visible"
45 exit="hidden"
46 >
47 <Copy size={16} />
48 </motion.span>
49 )}
50 </AnimatePresence>
51 </motion.button>
52 )
53}
54
55export default CopyPasteButton

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected