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

PropTypeDefaultDescription
contentstring-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.
classNamestring-The class name to apply to the component.
childrenReactNode-Optional children to render inside component.
asChildbooleanfalseWhether to merge props onto the immediate child.