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-reading-progress-bar-react

v1.0.1

Published

Top-of-page scroll progress bar for article pages

Readme

@molecule/app-reading-progress-bar-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 reading progress bar.

Exports <ReadingProgressBar> — a thin top-of-page bar that fills as the user scrolls through an article. Used by blog and news-aggregator article pages.

Quick Start

import { useRef } from 'react'
import { ReadingProgressBar } from '@molecule/app-reading-progress-bar-react'

const articleRef = useRef<HTMLElement>(null)

// Pin to top, track a specific article element
<ReadingProgressBar containerRef={articleRef} color="var(--brand)" thickness={4} />

// Simpler: track whole-page scroll
<ReadingProgressBar position="top" />

Type

feature

Installation

npm install @molecule/app-reading-progress-bar-react @molecule/app-react @molecule/app-ui react
npm install -D @types/react

API

Interfaces

ReadingProgressBarProps

Props for the {@link ReadingProgressBar} component.

interface ReadingProgressBarProps {
  /**
   * Optional ref to the article element. When provided, progress is
   * measured against that element's bounding rect (so the bar fills as the
   * user scrolls through the article body, not the whole page). When
   * omitted, progress falls back to `window` scroll position.
   */
  containerRef?: RefObject<Element | null>
  /** Bar thickness in pixels. Defaults to `3`. */
  thickness?: number
  /**
   * Where the bar pins. Defaults to `'top'`. Both variants render fixed
   * across the full viewport width with a high z-index.
   */
  position?: 'top' | 'bottom'
  /**
   * CSS color for the filled portion of the bar. Defaults to
   * `'currentColor'` so the bar inherits whatever text color is in scope —
   * letting the surrounding theme drive it. Pass an explicit color
   * (`'#3b82f6'`, `'var(--brand)'`, etc.) to override.
   */
  color?: string
  /** Extra classes on the outer wrapper. */
  className?: string
  /** `data-mol-id` for AI-agent / E2E selectors. */
  dataMolId?: string
}

Functions

computeArticleProgress(el, viewportHeight)

Computes the scroll progress (0..1) of an element, measured by how much of the element has scrolled past the top of the viewport.

Specifically:

  • Returns 0 when the element's top is at or below the viewport top.
  • Returns 1 when the element's bottom is at or above the viewport top plus the viewport height (i.e. the element has been fully read).
  • Linearly interpolates between those endpoints in the middle.

The same formula works whether the user reads inside window (no containerRef) or scrolls a fixed element — the bounding rect already accounts for the layout.

function computeArticleProgress(el: Element, viewportHeight: number): number
  • el — The article element whose read-through progress we want.
  • viewportHeight — The viewport height to use as the denominator.

Returns: A number in [0, 1].

computeWindowProgress()

Computes window scroll progress (0..1) using scrollY and the document's total scrollable height.

function computeWindowProgress(): number

Returns: A number in [0, 1]. Falls back to 0 when there is nothing to scroll (page shorter than the viewport).

ReadingProgressBar(props)

Top-of-page reading progress bar.

Tracks how far the user has scrolled through an article and renders a thin horizontal bar pinned to the top (or bottom) of the viewport, filling left-to-right from 0% to 100% as they read.

Throttles scroll updates with requestAnimationFrame so the work runs at most once per frame — handler attaches in passive mode.

Listens to both scroll and resize because progress changes when the viewport height changes (e.g. mobile toolbar collapse).

No containerRef → measures window. With containerRef → measures the element so the bar reflects progress through that specific article even when the page has additional scrollable content above/below.

function ReadingProgressBar({
  containerRef,
  thickness = 3,
  position = 'top',
  color,
  className,
  dataMolId,
}: ReadingProgressBarProps): ReactElement<unknown, string | JSXElementConstructor<any>>
  • props — Component props (see {@link ReadingProgressBarProps}).

Injection Notes

Requirements

Peer dependencies:

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

Runtime Dependencies

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

Companion locale bond: @molecule/app-locales-reading-progress-bar (the progressbar aria-label). The fill defaults to currentColor — it inherits the surrounding text color, so pass color (e.g. var(--color-primary)) when the ambient text color is low-contrast against the page edge. The bar renders position: fixed at z-index: 1000 spanning the viewport width; it only listens to window scroll — containerRef changes what is measured, not which scroller is observed (inner scroll containers won't drive it). Requires the app-react i18n provider and a wired ClassMap bond.

Translations

Translation strings are provided by @molecule/app-locales-reading-progress-bar.