Copy Button
A copy-to-clipboard button with a 2-second Copied confirmation that disables when there is nothing to copy and no-ops on an unavailable clipboard.
Copy Button
The Copy Button copies its value to the clipboard and shows a 2-second
"Copied" confirmation before reverting. It disables itself when there is nothing
to copy, and treats an unavailable clipboard (insecure context or denied
permission) as a silent no-op — so it never throws in a hostile environment.
Presentational + controlled. Pass the text via
value; the button owns only its transient "Copied" state. Use it beside any generated text, code block, or result.
When to use it: anywhere the user should be able to copy a value with clear visual confirmation — generated answers, model ids, export payloads, snippets.
Preview
Installation
pnpm dlx shadcn@latest add @localmode/ui/input-controls/copy-buttonnpx shadcn@latest add @localmode/ui/input-controls/copy-buttonyarn dlx shadcn@latest add @localmode/ui/input-controls/copy-buttonbunx --bun shadcn@latest add @localmode/ui/input-controls/copy-buttonDependencies
- Data source: copies the
valuestring you pass — works with any backend. lucide-react— the copy / check iconsclsx+tailwind-merge— via the sharedcn()util (installed automatically as a registry dependency)
Files installed
copy-button.tsx— the componentlib/utils.ts— thecn()helper (if not already present)
Props
CopyButton
Prop
Type
Examples
Copy a generated result
import { CopyButton } from '@/components/copy-button';
export function ResultToolbar({ text }) {
return <CopyButton value={text} />;
}Force-disable while streaming
<CopyButton value={partial} disabled={isStreaming} />Customization
The button uses border-border / hover:bg-muted token utilities and merges
your className. Because you own the copied file, you can change the confirmation
duration (the 2000 ms timeout), swap the icons, or make it icon-only.
Prompt Enhance Button
A one-click "enhance my prompt" control that rewrites the user's draft with a local model — fully offline — with an optional few-shot example editor.
System Prompt Editor
A controlled system-prompt editor with quick-pick presets composed via Option List — value in, onChange out; persistence stays in the consumer.