Components
Loading preview...
Copy to Clipboard Component
@lukacho
npx shadcn@latest add https://21st.dev/r/lukacho/copy-to-clipboard"use client"
import { CopyToClipboard } from "@/components/ui/copy-to-clipboard";
export function CopyToClipboardDemo() {
const codeExample = `const Button = ({ children, className }) => {
return (
<button
className={cn(
"px-4 py-2 rounded bg-blue-500",
className
)}
>
{children}
</button>
)
}`
return (
<div className="relative p-8 rounded-lg bg-neutral-50 dark:bg-neutral-950 font-mono text-sm">
<CopyToClipboard>
{codeExample}
</CopyToClipboard>
<pre>
<code>
{codeExample}
</code>
</pre>
</div>
)
}