copy-to-clipboard Repo
Basic text copy
copyToClipboard("Hello, I'm new content from your clipboard")
Click to copy sample text
Multiline text copy
This would be some multiline text for us to copy
Click to copy multiline text
Markup + text copy
Click to copy multiline text
Rich text (HTML) copy
copyToClipboard('<b>Hello <i>world</i></b>', { format: 'text/html' })
Click to copy rich text
Rich text with custom plain fallback
copyToClipboard('<b>Hello <i>world</i></b>', { format: 'text/html', onCopy: () => new ClipboardItem({ 'text/html': new Blob(['<b>Hello <i>world</i></b>'], { type: 'text/html' }), 'text/plain': new Blob(['Hello plain world'], { type: 'text/plain' }), }) })
Click to copy rich text with custom plain
Tab-separated + CRLF text copy
copyToClipboard("Dapibus\t1\r\nUltricies\t20\r\nInceptos\t444\r\n")
Click to copy tab/CRLF text
Copy inside modal dialog
copyToClipboard("Hello from dialog")
Open dialog and copy
This is a modal dialog.
Copy text from inside dialog
Close
Copy inside fullscreen element
// execCommand fails in fullscreen; navigator.clipboard works copyToClipboard("Hello from fullscreen")
Enter fullscreen and copy
You are in fullscreen mode.
Copy text from inside fullscreen
Exit fullscreen