Web · Components
CopyButton
A button that copies a value to the clipboard: on click the icon briefly becomes ✓ and "Copied" is read to the screen reader.
2 exports
Live example
Preview
sk_live_51H…a9XqCode
Events
- Events appear here when you interact with the preview.
Value from the server (a function; loading while waiting)
Import
A button that copies a value to the clipboard: on click the icon briefly becomes ✓ and "Copied" is read to the screen reader. Falls back to the old method when the Clipboard API is unavailable (http). Style and size are the same as Button.
For your own button see useClipboard.
Examples
CopyButtonProps
interfaceProps of the CopyButton component.
Extends: Omit<ButtonAsButtonProps, "value" | "children" | "onCopy" | "onError" | "icon">
| Name | Type | Default | Description |
|---|---|---|---|
value | ClipboardValue | (() => ClipboardValue | Promise<ClipboardValue>) | Value to copy: text, rich content ({ text, html }) or a function returning the value (can be a Promise; e.g. a share link from the server). The function is called only on click. | |
children? | ReactNode | Button text. When given a text button is drawn and copiedLabel appears after copying; otherwise an icon-only square button (its name is still label, shown as a tooltip). | |
label? | string | "Kopyala" | Name of the button (tooltip of the icon-only button). |
copiedLabel? | string | "Kopyalandı" | Name shown after copying. |
timeout? | number | 2000 | Duration of the "Copied" state (ms). |
onCopy? | (text: string) => void | Called with the copied text when copying succeeds. | |
onError? | (error: unknown) => void | Called when copying fails (no permission). |