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

@tkalve/prefect

v0.5.1

Published

A lightweight <pre> replacement with built-in line numbering and other developer-friendly enhancements.

Readme

Prefect

A lightweight React component that replaces the standard <pre> element with built-in line numbering, syntax-aware formatting, and developer-friendly enhancements.

Features

Line Numbers - Automatic line numbering with no configuration needed
📱 Responsive - Works seamlessly on all screen sizes
Accessible - Built with WCAG accessibility standards in mind
🎨 Customizable - Easy to style with CSS or CSS Modules
Lightweight - Minimal dependencies, optimized for performance

Installation

npm install @tkalve/prefect
# or
yarn add @tkalve/prefect
# or
pnpm add @tkalve/prefect

Quick Start

import { Prefect } from "@tkalve/prefect";

export function App() {
  const codeExample = `function hello() {
  console.log("Hello, world!");
}`;

  return <Prefect value={codeExample} />;
}

Usage

Basic Example

import { Prefect } from "@tkalve/prefect";

const code = `const greeting = "Hello, Prefect!";
console.log(greeting);`;

export function CodeBlock() {
  return <Prefect value={code} />;
}

With Custom Styling

import { Prefect } from "@tkalve/prefect";
import styles from "./MyCodeBlock.module.scss";

export function StyledCodeBlock() {
  return (
    <Prefect
      value="console.log('styled code');"
      className={styles.customCodeBlock}
    />
  );
}

Props

| Prop | Type | Description | | ----------- | -------- | ----------------------------------------- | | value | string | Required. The code content to display | | className | string | Optional CSS class for custom styling |

Styling & Customization

All Prefect styles are easily customizable using CSS custom properties (variables). Pass a className prop to your Prefect component and override any of the variables below.

CSS Custom Properties

Colors

| Property | Default (Light) | Default (Dark) | Description | | ------------------------ | ------------------ | ------------------------ | ------------------------ | | --prefect-bg | #fafafa | #1e1e1e | Background color | | --prefect-text | #000000 | #d4d4d4 | Text/code color | | --prefect-number-color | #9aa0a6 | #555555 | Line number color | | --prefect-border-color | #e5e5e5 | #333333 | Border and divider color | | --prefect-hover-bg | rgba(0,0,0,0.03) | rgba(255,255,255,0.05) | Hover background |

Spacing

| Property | Default | Description | | ------------------------------ | ------- | ------------------ | | --prefect-padding-vertical | 1rem | Top/bottom padding | | --prefect-padding-horizontal | 0 | Left/right padding | | --prefect-margin | 0 | Outer margin |

Line Numbers

| Property | Default | Description | | -------------------------------- | ------- | ----------------------------------- | | --prefect-number-padding-left | 1rem | Left padding of line number | | --prefect-number-padding-right | 1rem | Right padding of line number | | --prefect-number-min-width | 3ch | Minimum width of line number column | | --prefect-number-text-align | right | Alignment of line numbers | | --prefect-number-border-width | 1px | Width of divider line |

Code Content

| Property | Default | Description | | -------------------------------- | -------- | ---------------------------- | | --prefect-content-padding-left | 1.5rem | Left padding of code content | | --prefect-content-text-align | left | Alignment of code text |

Typography

| Property | Default | Description | | ------------------------- | ----------------------- | ------------- | | --prefect-font-family | "Consolas", monospace | Font family | | --prefect-font-size | 14px | Font size | | --prefect-line-height | 1.6 | Line height | | --prefect-border-radius | 8px | Border radius |

Simple Customization Example

.darkCodeBlock {
  --prefect-bg: #1a1a1a;
  --prefect-text: #e0e0e0;
  --prefect-number-color: #666;
  --prefect-border-color: #333;
  --prefect-padding-vertical: 1.5rem;
  --prefect-padding-horizontal: 1rem;
  --prefect-font-size: 13px;
}
import { Prefect } from "@tkalve/prefect";
import styles from "./MyCodeBlock.module.scss";

export function DarkCodeBlock() {
  return (
    <Prefect
      value="console.log('custom styled code');"
      className={styles.darkCodeBlock}
    />
  );
}

Theme Variants

Use the dark or light class names to force a theme:

<Prefect value={code} className="dark" />
<Prefect value={code} className="light" />

Accessibility

Prefect is built with accessibility in mind:

  • Line numbers are marked with aria-hidden="true" to avoid redundant screen reader announcements
  • Proper semantic HTML structure
  • Respects system contrast preferences
  • Empty lines are preserved with zero-width spaces for proper spacing

Browser Support

Modern browsers supporting ES2020 and React 19+

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT © Thomas Kalve

Repository