> For the complete documentation index, see [llms.txt](https://docs.corets.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.corets.io/helpers/clipboard-helpers.md).

# Clipboard Helpers

Source code is hosted on [GitHub](https://github.com/corets/clipboard-helpers)

{% tabs %}
{% tab title="yarn" %}

```bash
yarn add @corets/clipboard-helpers
```

{% endtab %}

{% tab title="npm" %}

```
npm install --save @corets/clipboard-helpers
```

{% endtab %}
{% endtabs %}

## copyToClipboard() <a href="#copytoclipboard" id="copytoclipboard"></a>

Copy a value to clipboard:

```typescript
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:

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

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