BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/ncdai/copy-button

Copy Button

ncdai/copy-button
UnverifiedComponent

Copy text to clipboard with visual, haptic, and audio feedback.

Install it

npx shadcn@latest add https://raw.githubusercontent.com/Sumeet011/Portfolio/main/public/r/copy-button.json

Source

src/registry/components/copy-button/copy-button.tsxraw.githubusercontent.com/Sumeet011/Portfolio/main/public/r/copy-button.json
1"use client"
2
3import type { ComponentProps } from "react"
4import { motion } from "motion/react"
5
6import { cn } from "@/lib/utils"
7import type { CopyState } from "@/hooks/use-copy-to-clipboard"
8import { useCopyToClipboard } from "@/hooks/use-copy-to-clipboard"
9import { Button } from "@/components/ui/button"
10import { IconSwap, IconSwapItem } from "@/registry/components/icon-swap"
11import { IconPlaceholder } from "@/registry/icons/icon-placeholder"
12
13export type CopyStateIconProps = {
14 state: CopyState
15 /** Custom icon for idle state. */
16 idleIcon?: React.ReactNode
17 /** Custom icon for done state. */
18 doneIcon?: React.ReactNode
19 /** Custom icon for error state. */
20 errorIcon?: React.ReactNode
21}
22
23export function CopyStateIcon({
24 state,
25 idleIcon,
26 doneIcon,
27 errorIcon,
28}: CopyStateIconProps) {
29 return (
30 <IconSwap>
31 <IconSwapItem key={state} as={motion.span}>
32 {state === "idle" &&
33 (idleIcon ?? (
34 <IconPlaceholder
35 data-slot="idle-icon"
36 lucide="CopyIcon"
37 tabler="IconCopy"
38 hugeicons="Copy01Icon"
39 phosphor="CopyIcon"
40 remixicon="RiFileCopyLine"
41 />
42 ))}
43
44 {state === "done" &&
45 (doneIcon ?? (
46 <IconPlaceholder
47 data-slot="done-icon"
48 lucide="CheckIcon"
49 tabler="IconCheck"
50 hugeicons="Tick02Icon"
51 phosphor="CheckIcon"
52 remixicon="RiCheckLine"
53 />
54 ))}
55
56 {state === "error" &&
57 (errorIcon ?? (
58 <IconPlaceholder
59 data-slot="error-icon"
60 lucide="CircleXIcon"
61 tabler="IconX"
62 hugeicons="CancelCircleIcon"
63 phosphor="XCircleIcon"
64 remixicon="RiCloseCircleLine"
65 />
66 ))}
67 </IconSwapItem>
68 </IconSwap>
69 )
70}
71
72export type CopyButtonProps = ComponentProps<typeof Button> & {
73 /** The text to copy, or a function that returns the text. */
74 text: string | (() => string)
75 /** Called with the copied text on successful copy. */
76 onCopySuccess?: (text: string) => void
77 /** Called with the error if the copy operation fails. */
78 onCopyError?: (error: Error) => void
79} & Omit<CopyStateIconProps, "state">
80
81export function CopyButton({
82 className,
83 size = "icon",
84 children,
85 text,
86 idleIcon,
87 doneIcon,
88 errorIcon,
89 onClick,
90 onCopySuccess,
91 onCopyError,
92 ...props
93// … truncated

What it pulls in

npm packages

  • lucide-react
  • motion
  • @rexa-developer/tiks
  • web-haptics

Other registry items

  • button

Files it writes

  • src/registry/components/copy-button/copy-button.tsx
  • src/hooks/use-copy-to-clipboard.ts

Facts

Registry
ncdai
Type
registry:component
Access
Unverified
Files written
2
Licence
MIT
First indexed
2026-08-04
Last confirmed
today

Go to the source

chanhdai.com Sumeet011/Portfolio on GitHub Raw registry item This item as JSON

More from ncdai

All 48 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Apple Hello Effectapple-hello-effectncdaiComponentsUnverified1 dep
Apple Hello Effect - Hindiapple-hello-effect-hindincdaiComponentsUnverified1 dep
Apple Hello Effect - Spanishapple-hello-effect-spanishncdaiComponentsUnverified1 dep
Apple Hello Effect - Vietnameseapple-hello-effect-vietnamesencdaiComponentsUnverified1 dep
Brand Assets Menubrand-assets-menuncdaiComponentsUnverified1 dep
chevrons-up-down-iconchevrons-up-down-iconncdaiComponentsUnverified1 dep
Code Block Commandcode-block-commandncdaiComponentsUnverified4 deps · 2 files
Consent Managerconsent-managerncdaiComponentsUnverified1 dep
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