BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/spell-ui/copy-button

Copy Button

spell-ui/copy-button
FreeComponent

A copy-to-clipboard button with blur transition effect.

Live preview

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

Install it

npx shadcn@latest add https://spell.sh/r/copy-button.json

Source

registry/spell-ui/copy-button.tsxspell.sh/r/copy-button.json
1"use client";
2
3import * as React from "react";
4import { CheckIcon, CopyIcon } from "lucide-react";
5import { cn } from "@/lib/utils";
6
7type SizeVariant = "sm" | "default" | "lg";
8
9interface CopyButtonProps
10 extends React.ButtonHTMLAttributes<HTMLButtonElement> {
11 value?: string;
12 size?: SizeVariant;
13}
14
15const sizeMap: Record<SizeVariant, { button: string; icon: number }> = {
16 sm: { button: "h-8 w-8", icon: 14 },
17 default: { button: "h-9 w-9", icon: 16 },
18 lg: { button: "h-12 w-12", icon: 20 },
19};
20
21const CopyButton = React.forwardRef<HTMLButtonElement, CopyButtonProps>(
22 (
23 {
24 value,
25 size = "default",
26 className,
27 onClick,
28 ...props
29 },
30 ref,
31 ) => {
32 const [copied, setCopied] = React.useState<boolean>(false);
33
34 const handleCopy = (event: React.MouseEvent<HTMLButtonElement>) => {
35 if (value) {
36 navigator.clipboard.writeText(value).catch(() => {});
37 }
38 setCopied(true);
39 setTimeout(() => setCopied(false), 1500);
40 onClick?.(event);
41 };
42
43 const { button: buttonSize, icon: iconSize } = sizeMap[size];
44
45 return (
46 <button
47 ref={ref}
48 type="button"
49 onClick={handleCopy}
50 aria-label={copied ? "Copied" : "Copy to clipboard"}
51 disabled={copied}
52 className={cn(
53 "relative cursor-pointer active:scale-[0.97] transition-all ease-out duration-200 inline-flex items-center justify-center rounded-md text-neutral-900 disabled:pointer-events-none disabled:opacity-100 dark:text-neutral-50",
54 buttonSize,
55 className,
56 )}
57 {...props}
58 >
59 <div
60 className={cn(
61 "transition-all duration-200",
62 copied
63 ? "scale-100 opacity-100 blur-none"
64 : "scale-70 opacity-0 blur-[2px]",
65 )}
66 >
67 <CheckIcon
68 size={iconSize}
69 strokeWidth={2}
70 aria-hidden="true"
71 />
72 </div>
73 <div
74 className={cn(
75 "absolute transition-all duration-200",
76 copied
77 ? "scale-0 opacity-0 blur-[2px]"
78 : "scale-100 opacity-100 blur-none",
79 )}
80 >
81 <CopyIcon size={iconSize} strokeWidth={2} aria-hidden="true" />
82 </div>
83 </button>
84 );
85 },
86);
87
88CopyButton.displayName = "CopyButton";
89
90export { CopyButton };
91export type { CopyButtonProps };

What it pulls in

npm packages

  • lucide-react

Files it writes

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

Facts

Registry
spell-ui
Type
registry:component
Access
Free
Files written
1
Licence
MIT
First indexed
2026-08-03
Last confirmed
yesterday

Go to the source

Docs on spell-ui spell.sh xxtomm/spell-ui on GitHub Raw registry item This item as JSON

More from spell-ui

All 33 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Animated Checkboxanimated-checkboxspell-uiComponentsFree1 dep
Animated Gradientanimated-gradientspell-uiComponentsFreeno deps
Badgebadgespell-uiComponentsFree2 deps
Bars Spinnerbars-spinnerspell-uiComponentsFreeno deps
Blur Revealblur-revealspell-uiComponentsFree1 dep
Chartchartspell-uiComponentsFreeno deps
Color Selectorcolor-selectorspell-uiComponentsFreeno deps
Exploding Inputexploding-inputspell-uiComponentsFreeno 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