Copy To Clipboard
Copies the given text to the clipboard.
Category | Functions |
Author | Pol Gubau |
Since | 1.0.0 |
Last Updated | 2025-03-15 |
Type | Async |
Compatibility | Browser |
Example
Input
await copyToClipboard('Hello, world!')
Output:
true
Return
Returns true if the text was successfully copied, otherwise false.
Type: boolean
Props
Name | Type | Default | Required | Description |
---|---|---|---|---|
text | string | null | Yes | The text to be copied to the clipboard. |
Notes
This function uses the `navigator.clipboard.writeText` API to copy text to the clipboard.
Errors
Warning if clipboard is not supported.
Tags
- clipboard
- copy
- text