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

@papit/codeblock

v0.1.4

Published

A block to highlight and preview code, used for display purposes - uses highlight.js

Readme

@papit/codeblock

A web component for previewing and syntax-highlighting HTML, CSS, and JavaScript — with no external dependencies. Built on @papit/lexer for zero-overhead tokenization.

Logo


Type Tests NPM version


Features

  • Syntax highlighting for HTML, CSS, and JavaScript via @papit/lexer
  • Live preview panel with optional splitter (display attribute)
  • Light/dark scheme toggle — detects and tracks the ambient color scheme from parent elements and system preference
  • Collapse/expand code view with a fade-out peek
  • One-click copy to clipboard
  • Checkerboard, canvas, or solid background for the preview area
  • No external dependencies

Installation

npm install @papit/codeblock

Usage

<script type="module">
  import "@papit/codeblock";
</script>

<pap-codeblock>
  <p>Hello world</p>
  <style>
    p { color: red; }
  </style>
  <script>
    console.log("hello");
  </script>
</pap-codeblock>

Slot any HTML content directly — the component captures the raw HTML, formats it, and syntax-highlights it. <style> and <script> tags are detected and highlighted accordingly.

With live preview

<pap-codeblock display>
  <div>
    <span>yes</span>
    <span>no</span>
  </div>
</pap-codeblock>

The display attribute enables the preview panel with a draggable splitter between the rendered output and the code view.


Attributes

| Attribute | Type | Default | Description | |-----------|------|---------|-------------| | display | boolean | false | Enables the live preview panel | | color | "checker" \| "canvas" \| "background" | "checker" | Background style for the preview area |

color values

  • checker — checkerboard pattern, useful for spotting transparency
  • canvas — solid canvas color from the design token
  • background — solid background color from the design token

Color scheme

The component tracks the ambient color-scheme from its parent elements and the system preference. The toggle in the header flips between the ambient scheme and its opposite — so if the page is in dark mode, the toggle switches to light, and vice versa.

If the ambient scheme changes (e.g. a parent element's class is toggled), the component updates automatically as long as the toggle is in its default position.


CSS custom properties

The code block exposes its theme tokens for customization:

| Property | Description | |----------|-------------| | --ch-bg | Code background | | --ch-text | Default code text | | --ch-keyword | Keywords (const, function, if, ...) | | --ch-keyword-2 | Secondary keywords (async, await, while) | | --ch-identifier | Identifiers and variable names | | --ch-string | String literals | | --ch-number | Numeric literals | | --ch-operator | Operators | | --ch-punctuation | Punctuation | | --ch-comment | Comments |

All tokens use light-dark() and respond to the component's color-scheme.


Contributing

Contributions are welcome. Follow the development guidelines and ensure all tests pass before submitting a pull request.


License

Licensed under the @Papit License 1.0 — Copyright (c) 2024 Henry Pap (@onkelhoy)

Key points:

  • ✅ Free to use in commercial projects
  • ✅ Free to modify and distribute
  • ✅ Attribution required
  • ❌ Cannot resell the component itself as a standalone product

See the LICENSE file for full details.


Related


Support

For issues, questions, or contributions, visit the GitHub repository.