MCPcopy Index your code
hub / github.com/SyntaxUI/syntaxui / CopyButton

Function CopyButton

src/components/icons/CopyButton.tsx:22–66  ·  view source on GitHub ↗
({
  value,
  className,
  src,
  variant = 'ghost',
  event,
  ...props
}: CopyButtonProps)

Source from the content-addressed store, hash-verified

20}
21
22export function CopyButton({
23 value,
24 className,
25 src,
26 variant = 'ghost',
27 event,
28 ...props
29}: CopyButtonProps) {
30 const [hasCopied, setHasCopied] = React.useState(false)
31
32 React.useEffect(() => {
33 setTimeout(() => {
34 setHasCopied(false)
35 }, 2000)
36 }, [hasCopied])
37
38 return (
39 <Button
40 size="icon"
41 variant={variant}
42 className={cn(
43 'relative z-10 h-6 w-6 text-zinc-50 hover:bg-zinc-700 hover:text-zinc-50 [&_svg]:size-3',
44 className,
45 )}
46 onClick={() => {
47 copyToClipboardWithMeta(
48 value,
49 event
50 ? {
51 name: event,
52 properties: {
53 code: value,
54 },
55 }
56 : undefined,
57 )
58 setHasCopied(true)
59 }}
60 {...props}
61 >
62 <span className="sr-only">Copy</span>
63 {hasCopied ? <CheckIcon /> : <ClipboardIcon />}
64 </Button>
65 )
66}

Callers

nothing calls this directly

Calls 2

cnFunction · 0.90
copyToClipboardWithMetaFunction · 0.85

Tested by

no test coverage detected