npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tuyuritio/shiki-code-copy

v1.0.0

Published

Shiki plugin to add copy button to code blocks.

Readme

Shiki Code Copy

Shiki transformer that adds a copy-to-clipboard button to code blocks.

Install

pnpm add @tuyuritio/shiki-code-copy

Usage

import codeCopy from "@tuyuritio/shiki-code-copy";
import { codeToHtml } from "shiki";

const html = await codeToHtml('console.log("hello")', {
  lang: "js",
  theme: "github-dark",
  transformers: [
    codeCopy({ duration: 1500 })
  ]
});

Options

| Option | Type | Default | Description | | --- | --- | --- | --- | | duration | number | 1500 | Duration in milliseconds for the "copied" state visual feedback. |

How It Works

The transformer wraps the code block's <code> element in a <div.code-container> and appends a <button> with an inline onclick handler that:

  1. Copies the source code to the clipboard via navigator.clipboard.writeText()
  2. Adds a code-copied class to the button for visual feedback
  3. Removes the code-copied class after the specified duration

Output Structure

<pre>
  <div class="code-container">
    <code>...</code>
    <button type="button" class="code-copy-button" aria-hidden="true">
      <svg class="copy-icon"><!-- clipboard icon --></svg>
      <svg class="done-icon"><!-- checkmark icon --></svg>
    </button>
  </div>
</pre>

Icons

The button contains two SVG icons:

  • copy-icon — clipboard icon, shown by default
  • done-icon — checkmark icon, shown when code is copied

Styling

The plugin only injects the HTML structure. You need to provide your own CSS to style the button and handle the icon toggle. Here's a minimal example:

.code-container {
  position: relative;
}

.code-copy-button {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0.25rem;
  color: inherit;
  opacity: 0;
  transition: opacity 0.2s;
}

.code-container:hover .code-copy-button {
  opacity: 1;
}

.code-copy-button .done-icon {
  display: none;
}

.code-copy-button.code-copied .copy-icon {
  display: none;
}

.code-copy-button.code-copied .done-icon {
  display: block;
}

CSS Classes

| Class | Element | Description | | --- | --- | --- | | code-container | <div> | Wrapper around code and button | | code-copy-button | <button> | The copy button | | code-copied | <button> | Added temporarily after copying | | copy-icon | <svg> | Clipboard icon | | done-icon | <svg> | Checkmark icon |

License

GPL-3.0-or-later