copy-button
vengenceui/copy-buttonFreeComponent
vengenceui publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by vengenceui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.vengenceui.com/r/copy-button.jsonSource
1"use client";23import * as React from "react";4import { Check, Copy } from "lucide-react";5import { cn } from "@/lib/utils";67export function CopyButton({ code, className }: { code: string; className?: string }) {8 const [hasCopied, setHasCopied] = React.useState(false);910 React.useEffect(() => {11 if (!hasCopied) return;12 const timeout = setTimeout(() => {13 setHasCopied(false);14 }, 2000);15 return () => clearTimeout(timeout);16 }, [hasCopied]);1718 return (19 <button20 className={cn(21 "relative z-10 flex h-7 w-7 items-center justify-center rounded-md border bg-zinc-900 border-zinc-800 text-zinc-400 hover:bg-zinc-800 hover:text-zinc-50 transition-colors",22 className23 )}24 onClick={() => {25 navigator.clipboard.writeText(code);26 setHasCopied(true);27 }}28 >29 <span className="sr-only">Copy</span>30 {hasCopied ? (31 <Check className="h-3.5 w-3.5 text-emerald-400" />32 ) : (33 <Copy className="h-3.5 w-3.5" />34 )}35 </button>36 );37}
What it pulls in
npm packages
Files it writes
More from vengenceui
All 128 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | vengenceui | Components | Free | 2 deps | |
| agent-bento-gridagent-bento-grid | vengenceui | Components | Free | 1 dep | |
| alertalert | vengenceui | Components | Free | no deps | |
| animated-buttonanimated-button | vengenceui | Components | Free | 1 dep | |
| animated-footeranimated-footer | vengenceui | Components | Free | 2 deps | |
| animated-numberanimated-number | vengenceui | Components | Free | 1 dep | |
| animated-raysanimated-rays | vengenceui | Components | Free | no deps | |
| animated-tooltipanimated-tooltip | vengenceui | Components | Free | 1 dep |
