Docs
Copy
Copy
Copies text to clipboard with visual feedback.
Copy Plain Text
Copy text to clipboard with visual feedback
This is sample text that will be copied to clipboard.
Custom Button Implementation
Installation
Usage
import { Copy } from "@/components/ui/copy";<Copy content="Text to be copied" onCopy={() => console.log("Copied!")} />;
{
/* With children */
}
<Copy content="Text to be copied">Click to copy</Copy>;
{
/* HTML mode */
}
<Copy content="<strong>HTML</strong> content" copyMode="HTML" />;
{
/* With asChild */
}
<Copy content="Text to be copied" asChild>
<Button>Copy text</Button>
</Copy>;Props
| Prop | Type | Default | Description |
|---|---|---|---|
content | string | - | The text or HTML content to copy to clipboard. |
copyMode | "TEXT" | "HTML" | "TEXT" | Mode to control how content is copied. |
onCopy | () => void | - | Function called when content is copied. |
className | string | - | The class name to apply to the component. |
children | ReactNode | - | Optional children to render inside component. |
asChild | boolean | false | Whether to merge props onto the immediate child. |