Icon-only copy button
Useful when the surrounding layout already shows the full value.
<CwCopy value={device.serialNumber} />Click-to-copy button with animated visual feedback. Pass any string as value.
Just the copy button — hover to see the clipboard icon, click to copy.
Hello, CropWatch! Pass children to display the value alongside the button.
sk-proj-abc123def456ghi789 <CwCopy value="sk-proj-abc123def456">
<code>sk-proj-abc123def456</code>
</CwCopy>Hello, CropWatch! Hello, CropWatch! Hello, CropWatch! eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkNyb3BXYXRjaCJ9 The onCopy prop fires after a successful copy. Counter: 0
CwCopy handles the clipboard action and temporary copied feedback. You choose the string to copy, and optionally render visible content next to the button.
| API | Type | Details |
|---|---|---|
value Required | string | Text written to the clipboard. |
size Default: | 'sm' | 'md' | 'lg' | Size preset for the copy affordance. |
feedbackDuration Default: | number | How long the copied feedback state stays visible. |
children | Snippet | Optional visible content rendered before the copy button. |
onCopy | (value: string) => void | Runs after a successful copy operation. |
These snippets intentionally show the full public API surface the live demo relies on.
Useful when the surrounding layout already shows the full value.
<CwCopy value={device.serialNumber} />Use this when the user should see exactly what will be copied.
<script lang="ts">
let copiedCount = $state(0);
</script>
<CwCopy
value="sk-proj-abc123def456ghi789"
size="lg"
feedbackDuration={2500}
onCopy={() => (copiedCount += 1)}
>
<code>sk-proj-abc123def456ghi789</code>
</CwCopy>