From 86aed30789dfa749ff75d25b94303fda225013bb Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Sun, 20 Apr 2025 15:21:05 -0700 Subject: [PATCH] docs(copy-button): improve docs --- docs/src/pages/components/CopyButton.svx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/src/pages/components/CopyButton.svx b/docs/src/pages/components/CopyButton.svx index d13e7caa..88eaed24 100644 --- a/docs/src/pages/components/CopyButton.svx +++ b/docs/src/pages/components/CopyButton.svx @@ -3,28 +3,32 @@ import Preview from "../../components/Preview.svelte"; -This component uses the native, asynchronous [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText) to copy text. +`CopyButton` lets users copy text to their clipboard with a single click. Use it to provide quick access to code snippets, links, or other text content. -You can override the default copy functionality with your own implementation. See [Overriding copy functionality](#overriding-copy-functionality). +This component uses the native [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText) to copy text. Override the default copy functionality with your own implementation. See [Overriding copy functionality](#overriding-copy-functionality). ## Default +Create a copy button with the `text` prop to specify what to copy. + ## Custom feedback text +Set `feedback` to customize the message shown after copying. + ## Overriding copy functionality -To override the default copy behavior, pass a custom function to the `copy` prop. +Pass a custom function to the `copy` prop to override the default copy behavior. -In this example, we use the open source module [clipboard-copy](https://github.com/feross/clipboard-copy) to copy the text instead of the default Clipboard API. +This example uses the NPM package [clipboard-copy](https://github.com/feross/clipboard-copy) to copy the text instead of the default Clipboard API. ## Preventing copy functionality -To prevent text from being copied entirely, pass a no-op function to the `copy` prop. +Pass a no-op function to the `copy` prop to disable copying. - {}} /> \ No newline at end of file + {}} />