Clipboard Helpers

Various helpers related to clipboard specific functionality.

Source code is hosted on GitHub

yarn add @corets/clipboard-helpers

copyToClipboard()

Copy a value to clipboard:

import { copyToClipboard } from "@corets/clipboard-helpers"

copyToClipboard("some value")

Behind the scenes, a hidden input element is rendered to perform the copy action. Sometimes you might want to specify a custom render target, for example when using a focus trap:

import { copyToClipboard } from "@corets/clipboard-helpers"

copyToClipboard("some value", "#target")
// or
copyToClipboard("some value", document.getElementById("target"))

Last updated