BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/blode/ui/copy-button

Copy Button

blode-ui/copy-button
FreeComponent

A button that copies text to the clipboard with animated feedback.

Install it

npx shadcn@latest add https://raw.githubusercontent.com/mblode/blode-ui/main/public/r/copy-button.json

Source

ui/copy-button.tsxraw.githubusercontent.com/mblode/blode-ui/main/public/r/copy-button.json
1"use client";
2
3import { CheckIcon, ClipboardIcon } from "blode-icons-react";
4import { AnimatePresence, motion } from "motion/react";
5import type * as React from "react";
6
7import { cn } from "@/lib/utils";
8import { useCopyToClipboard } from "@/hooks/use-copy-to-clipboard";
9import { Button } from "@/components/ui/button";
10
11export interface CopyButtonProps extends Omit<
12 React.ComponentProps<typeof Button>,
13 "onClick" | "children"
14> {
15 /** Accessible label (default: "Copy") */
16 label?: string;
17 /** Callback when text is copied */
18 onCopy?: () => void;
19 /** Timeout in ms before resetting (default: 2000) */
20 timeout?: number;
21 /** The text to copy to clipboard */
22 value: string;
23}
24
25const CopyButton = ({
26 value,
27 className,
28 variant = "ghost",
29 size = "icon",
30 onCopy,
31 timeout = 2000,
32 label = "Copy",
33 ...props
34}: CopyButtonProps) => {
35 const { isCopied, copyToClipboard } = useCopyToClipboard({
36 onCopy,
37 timeout,
38 });
39
40 return (
41 <Button
42 aria-label={label}
43 className={cn("shrink-0", className)}
44 data-copied={isCopied}
45 data-slot="copy-button"
46 onClick={() => copyToClipboard(value)}
47 size={size}
48 variant={variant}
49 {...props}
50 >
51 <AnimatePresence initial={false} mode="wait">
52 <motion.span
53 animate={{ opacity: 1, scale: 1 }}
54 className="flex items-center justify-center"
55 exit={{ opacity: 0, scale: 0.8 }}
56 initial={{ opacity: 0, scale: 0.8 }}
57 key={isCopied ? "check" : "copy"}
58 transition={{ duration: 0.15 }}
59 >
60 {isCopied ? <CheckIcon /> : <ClipboardIcon />}
61 </motion.span>
62 </AnimatePresence>
63 </Button>
64 );
65};
66
67export { CopyButton };

What it pulls in

npm packages

  • blode-icons-react
  • motion

Other registry items

  • button
  • @blode/use-copy-to-clipboard

Files it writes

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

Facts

Registry
blode/ui
Type
registry:ui
Access
Free
Files written
1
Licence
MIT
First indexed
2026-08-01
Last confirmed
today

Go to the source

blode.co mblode/blode-ui on GitHub Raw registry item This item as JSON

More from blode/ui

All 85 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Accordionaccordionblode/uiComponentsFree2 deps
Alertalertblode/uiComponentsFreeno deps
Alert Dialogalert-dialogblode/uiComponentsFree1 dep
Ask User Questionsask-user-questionsblode/uiComponentsFree1 dep
Aspect Ratioaspect-ratioblode/uiComponentsFree1 dep
Attachmentattachmentblode/uiComponentsFree1 dep
Autocompleteautocompleteblode/uiComponentsFree1 dep
Avataravatarblode/uiComponentsFree1 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