Copy button

Copies text and answers with a tick, or a cross if the browser refused, then turns back. It never changes size.

npm i github:ziyam-khan/runets

Features

  • Copy, tick and cross stacked in one cell and swapped in CSS, so the button never resizes.
  • The text can be a function, read at the moment of copying.
  • A polite status says Copied or Copy failed.

Use it for

  • Email addresses, links, code blocks.

On this site

Installation

  1. Get runets.
    git clone https://github.com/ziyam-khan/runets
  2. Copy these files into your project, keeping their folders.
  3. Install what they use.
    pnpm add react lucide-react
  4. Load the styles once. Bring your own base tokens, or use runets’ default theme.
    import 'runets/styles/theme.css'
    import 'runets/styles/kit.css'

API

PropTypeWhat it does
textstring | () => stringWhat to copy.
labelstringThe accessible name (Copy).
onCopied / onFailedfunctionsTell the rest of the page.
resetnumberms before it turns back (1500).

Accessibility

Source

The code is in src/kit/copy-button.tsx in runets, MIT licensed.