1 import { ComponentExample } from "@/components/ComponentExample"
2 import { ComponentReference } from "@/components/ComponentReference"
3
4 export const metadata = {
5 title: `Copy`,
6 }
7
8 # {metadata.title}
9
10 A component that wraps content in a button with copy functionality. It is useful for quickly copying text to the clipboard, such as code snippets or configuration commands.
11
12 In this guide, you'll learn how to use the Copy component.
13
14 <ComponentExample name="copy-demo" />
15
16 ## Usage
17
18 ```tsx
19 import { Copy } from "@medusajs/ui"
20 ```
21
22 ```tsx
23 <Copy content="yarn add @medusajs/ui" />
24 ```
25
26 ---
27
28 ## API Reference
29
30 <ComponentReference mainComponent="Copy" />
31
32 ---
33
34 ## Usage Outside Medusa Admin
35
36 If you're using the `Copy` component in a project other than the Medusa Admin, make sure to include the `TooltipProvider` somewhere up in your component tree, as the `Copy` component uses a [Tooltip](../tooltip/page.mdx#usage-outside-medusa-admin):
37
38 ```tsx
39 <TooltipProvider>
40 <Copy content="yarn add @medusajs/ui" />
41 </TooltipProvider>
42 ```
43
44 ---
45
46 ## Examples
47
48 ### Copy with Custom Display
49
50 <ComponentExample name="copy-custom-display" />
51
52 ### Copy Display As Child
53
54 Using the `asChild` prop, you can render the `<Copy/>` as its child. This is useful if you want to render a custom button, to prevent rendering a button inside a button.
55
56 <ComponentExample name="copy-as-child" hideFeedback />