Getting started

Getting started

Install the package, import the stylesheet once, then turn any button into a copy button.

Install

npm install @reuse-sh/interactions

Use it

The browser module works without a framework. In React, the component creates the same controller when it mounts and destroys it when it unmounts.

import { createCopyButton } from "@reuse-sh/interactions";
import "@reuse-sh/interactions/styles.css";

// <button class="copy" aria-label="Copy command"></button>
const copy = createCopyButton(document.querySelector(".copy"), {
  text: "npm install @reuse-sh/interactions",
});

// Later, when the button leaves the page
copy.destroy();

Hand this page to your coding agent.

Read https://reuse.sh/copy-button/guide.md, install @reuse-sh/interactions and add Copy button to <where>. Keep the principles the guide lists.