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

@substrate-system/code-block

v0.0.2

Published

Code block web component

Downloads

255

Readme

code-block

tests types module install size GZip size semantic versioning Common Changelog license

A web component that renders a <pre><code> block with an internal copy icon button.

See a live demo

Install

npm i -S @substrate-system/code-block

Example

import '@substrate-system/code-block'
import '@substrate-system/code-block/css'
<code-block>
  const answer = 42
</code-block>

API

This package exposes ESM and CommonJS via package.json exports field.

@substrate-system/code-block

Full component (render + hydrate). It registers <code-block> when imported.

import '@substrate-system/code-block'
import '@substrate-system/code-block/css'
<code-block>
  const answer = 42
</code-block>

@substrate-system/code-block/client

Client-only behavior (hydration only). Use this to hydrate HTML that was rendered on the server.

import { define } from '@substrate-system/code-block/client'
import '@substrate-system/code-block/css'

define()

@substrate-system/code-block/html

Server-side HTML renderer.

import { CodeBlock } from '@substrate-system/code-block/html'

const html = CodeBlock({
  code: 'console.log("hello")',
  copyHint: true,
  copyButtonLabel: 'Copy code to clipboard'
})

CodeBlock.outerHTML(options, attrs) is also provided to generate the host element wrapper.

CommonJS

require('@substrate-system/code-block')

CSS

Import CSS

import '@substrate-system/code-block/css'

Or minified:

import '@substrate-system/code-block/min/css'

Attributes

Supported on <code-block>:

  1. hint — Enables copy feedback hint when present. Use hint="false" to disable.
  2. copy-button-label — Accessible label/title for the icon button. Default: Copy code to clipboard.

SSR + Hydration Example

Server

import { CodeBlock } from '@substrate-system/code-block/html'

const html = CodeBlock.outerHTML({
  code: 'npm i -S @substrate-system/code-block'
})

Client

import { define } from '@substrate-system/code-block/client'
import '@substrate-system/code-block/css'

define()

Pre-built Files

This package exposes minified JS/CSS in dist/.

Copy

cp ./node_modules/@substrate-system/code-block/dist/index.min.js ./public/code-block.min.js
cp ./node_modules/@substrate-system/code-block/dist/index.min.css ./public/code-block.css

HTML

<head>
    <link rel="stylesheet" href="./code-block.css">
</head>
<body>
    <code-block>console.log('hello')</code-block>
    <script type="module" src="./code-block.min.js"></script>
</body>