BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/delta-components/copy-button

copy-button

delta-components/copy-button
FreeComponent

delta-components publishes no description for this item.

Live preview

live · rendered by the registry
Rendered by delta-components on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://deltacomponents.dev/r/copy-button.json

Source

components/ui/copy-button.tsxdeltacomponents.dev/r/copy-button.json
1"use client"
2
3import * as React from "react"
4import { CheckIcon, CopyIcon } from "lucide-react"
5
6import { cn } from "@/lib/utils"
7import { Button } from "@/components/ui/button"
8
9export function copyToClipboard(value: string) {
10 navigator.clipboard.writeText(value)
11}
12
13interface CopyButtonProps extends React.ComponentProps<typeof Button> {
14 value: string
15 variant?:
16 | "ghost"
17 | "outline"
18 | "secondary"
19 | "default"
20 | "destructive"
21 | "link"
22 iconColor?: string
23}
24
25export function CopyButton({
26 value,
27 className,
28 variant = "secondary",
29 iconColor,
30 ...props
31}: CopyButtonProps) {
32 const [hasCopied, setHasCopied] = React.useState(false)
33
34 React.useEffect(() => {
35 if (hasCopied) {
36 const timer = setTimeout(() => {
37 setHasCopied(false)
38 }, 2000)
39 return () => clearTimeout(timer)
40 }
41 }, [hasCopied])
42
43 return (
44 <Button
45 data-slot="copy-button"
46 size="icon"
47 variant={variant}
48 className={cn(
49 "hover:bg-muted active:bg-muted size-7 border-none bg-transparent shadow-none",
50 className
51 )}
52 onClick={() => {
53 copyToClipboard(value)
54 setHasCopied(true)
55 }}
56 {...props}
57 >
58 <span className="sr-only">Copy</span>
59 <div className="relative">
60 <div
61 className={cn(
62 "absolute inset-0 flex items-center justify-center transition-all duration-300 ease-in-out will-change-[transform,opacity,filter]",
63 hasCopied
64 ? "blur-0 scale-100 opacity-100"
65 : "scale-[0.25] opacity-0 blur-xs"
66 )}
67 >
68 <CheckIcon
69 className="h-3.5 w-3.5"
70 style={iconColor ? { color: iconColor } : {}}
71 />
72 </div>
73 <div
74 className={cn(
75 "transition-[transform,opacity,filter] duration-300 ease-in-out will-change-[transform,opacity,filter]",
76 hasCopied
77 ? "scale-[0.25] opacity-0 blur-xs"
78 : "blur-0 scale-100 opacity-100"
79 )}
80 >
81 <CopyIcon
82 className="h-3.5 w-3.5"
83 style={iconColor ? { color: iconColor } : {}}
84 />
85 </div>
86 </div>
87 </Button>
88 )
89}

What it pulls in

npm packages

  • lucide-react

Other registry items

  • button
  • tooltip

Files it writes

  • registry/delta-ui/delta/copy-button.tsx

Facts

Registry
delta-components
Type
registry:ui
Access
Free
Files written
1
Licence
MIT
First indexed
2026-08-04
Last confirmed
today

Go to the source

Docs on delta-components deltacomponents.dev pprunty/deltacomponents.dev on GitHub Raw registry item This item as JSON

More from delta-components

All 93 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
admonitionadmonitiondelta-componentsComponentsFree1 dep
cambio-imagecambio-imagedelta-componentsComponentsFree2 deps
card-deckcard-deckdelta-componentsComponentsFree3 deps
chatchatdelta-componentsComponentsFree3 deps
code-blockcode-blockdelta-componentsComponentsFree3 deps
code-block-iconscode-block-iconsdelta-componentsComponentsFreeno deps
input-otpinput-otpdelta-componentsComponentsFree1 dep
mapbox-pointermapbox-pointerdelta-componentsComponentsFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex