The Clipboard API provides the ability to respond to clipboard commands (cut, copy, and paste) as well as to asynchronously read from and write to the system clipboard. Access to the contents of the clipboard is gated behind the Permissions API; without user permission, reading or altering the clipboard contents is not permitted.
Note!
This API is designed to supersede accessing the clipboard using document.execCommand().
# StateThe useClipboard
function exposes the following reactive state:
string
the current text in the clipboard. # Methods
The useClipboard
function exposes the following methods:
write(str: string)
Writes the given string it in the clipboard. # Use-cases
I'm sure you can think of multiple situations where you would like to copy the clipboard text or write some data into them. Mainly stuff like copying code in snippets, referral links, recovery codes or really any hard to remember text.
# ExampleRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4