@solid-primitives/clipboard

Primitives for reading and writing to clipboard.

Usage no npm install needed!

<script type="module">
  import solidPrimitivesClipboard from 'https://cdn.skypack.dev/@solid-primitives/clipboard';
</script>

README

@solid-primitives/clipboard

lerna size size stage

Primitive to that make reading and writing to single or multiple values to clipboard easy. It also comes with a convenient directive to write to clipboard.

Installation

npm install @solid-primitives/clipboard
# or
yarn add @solid-primitives/clipboard

How to use it

createClipboard

Clipboard exports a read and write function. Note the write function is exported first for convenience as the most common use case for this primitive.

const [setClipboard, clipboard] = createClipboard();
setClipboard("foobar");

copyToClipboard

You can also use clipboard as a convenient directive for setting the clipboard value.

import { copyToClipboard } from "@solid-primitives/clipboard";
<input type="text" use:copyToClipboard={{ highlight: true }} />;

Demo

You may view a working example here: https://codesandbox.io/s/solid-primitives-clipboard-g14dh?file=/src/clipboard.ts

Changelog

Expand Changelog

1.0.0

Committing first version of primitive.

1.2.7

Added proper SSR support and modified documentation.

1.2.8

Upgraded to Solid 1.3