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

@molecule/app-code-block-react

v1.0.1

Published

React CodeBlock with language label, line numbers, copy-to-clipboard

Downloads

512

Readme

@molecule/app-code-block-react

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

React code block display.

Exports <CodeBlock> — read-only code panel with optional filename + language header, line numbers, and copy-to-clipboard button.

Quick Start

import { CodeBlock } from '@molecule/app-code-block-react'

;<CodeBlock
  code={`const greet = (name: string) => \`Hello, \${name}!\``}
  language="ts"
  filename="greet.ts"
  showLineNumbers
/>

Type

feature

Installation

npm install @molecule/app-code-block-react @molecule/app-react @molecule/app-ui @molecule/app-ui-react react
npm install -D @types/react

API

Interfaces

CodeBlockProps

Props for {@link CodeBlock}.

interface CodeBlockProps {
  /** Source code to display. */
  code: string
  /** Language tag (`"ts"`, `"bash"`, …). Shown in the header and used as a hint by external highlighters. */
  language?: string
  /** Show line numbers. Defaults to true. */
  showLineNumbers?: boolean
  /** Show a copy-to-clipboard button. Defaults to true. */
  showCopy?: boolean
  /** Optional custom filename / caption shown left of the language. */
  filename?: string
  /** Extra classes. */
  className?: string
}

Functions

CodeBlock(props)

Read-only code block with an optional header (filename + language tag), optional line numbers, and a copy-to-clipboard button.

Does NOT perform syntax highlighting, and code is always rendered as escaped plain text — passing pre-highlighted HTML displays literal tags. To highlight, wrap or replace this component with your highlighter's (e.g. prismjs, shiki) own renderer. The component keeps the no-hidden-dependency contract typical of @molecule/* features.

function CodeBlock({
  code,
  language,
  showLineNumbers = true,
  showCopy = true,
  filename,
  className,
}: CodeBlockProps): JSX.Element
  • props — Component props (see {@link CodeBlockProps}).

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-react ^1.0.1
  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-react ^1.0.1
  • react ^18.0.0 || ^19.0.0

Runtime Dependencies

  • @molecule/app-react
  • @molecule/app-ui
  • @molecule/app-ui-react
  • react

code is rendered as PLAIN TEXT — there is no syntax highlighting and no HTML parsing, so do not pass pre-highlighted HTML (it will display as literal tags). To highlight, wrap or replace this component with one that renders your highlighter's output; language is only a header label. The copy button uses navigator.clipboard and silently does nothing on insecure (non-HTTPS) contexts. Copy/Copied labels are translated via the codeBlock.* keys (companion bond: @molecule/app-locales-code-block).

Translations

Translation strings are provided by @molecule/app-locales-code-block.