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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@jamalofficial/top-progress-bar

v1.0.3

Published

Lightweight customizable top progress bar for React (global with hook support)

Readme

🟦 Top Progress Bar

A lightweight, customizable top-loading progress bar for React apps. Designed to be globally accessible with the useTopBar() hook and no external dependencies. Ideal for showing loading states during async operations like route transitions, API calls, or dynamic UI rendering.


🚀 Features

  • 🔁 Global control with useTopBar()
  • ⏱ Continuous, step, and manual percentage modes
  • 🎨 Customizable color, height, and animation speed
  • 💡 Zero dependencies — pure React + CSS
  • 🌐 SSR-friendly and easy to integrate into any React project

📦 Installation

npm install top-progress-bar
# or
pnpm add top-progress-bar
# or
yarn add top-progress-bar

🛠️ Usage

1️⃣ Wrap your app in the TopProgressBarProvider

// App.jsx or Layout.jsx
import { TopProgressBarProvider } from 'top-progress-bar';

function App() {
  return (
    <TopProgressBarProvider color="#1d4ed8" height="3px" speed={300}>
      <YourApp />
    </TopProgressBarProvider>
  );
}

2️⃣ Use the useTopBar hook anywhere

import { useTopBar } from 'top-progress-bar';

function ExampleComponent() {
  const { start, step, set, complete } = useTopBar();

  const handleLoad = async () => {
    start();                  // auto-starts at 5%, increases automatically
    await delay(1000);
    step(20);                 // add 20%
    await delay(500);
    set(80);                  // jump to 80%
    await delay(500);
    complete();               // fill to 100% then hide
  };

  return <button onClick={handleLoad}>Load Something</button>;
}

function delay(ms) {
  return new Promise((res) => setTimeout(res, ms));
}

⚙️ API

TopProgressBarProvider Props

| Prop | Type | Default | Description | | -------- | -------- | --------- | ------------------------------------------ | | color | string | #2563eb | The color of the progress bar | | height | string | 4px | Height of the bar (e.g., "3px", "5px") | | speed | number | 300 | Auto-progress speed (ms interval) |


useTopBar() Hook

Provides access to control functions:

| Method | Description | | ------------ | ---------------------------------------------------- | | start() | Starts auto-incrementing progress bar | | step(n) | Increases progress by n percent (e.g., step(10)) | | set(n) | Sets the exact progress (e.g., set(80)) | | complete() | Finishes the bar at 100%, then hides after a delay |

❗ The bar is automatically hidden when complete() is called or set(100) is reached.


🧪 Example

const bar = useTopBar();

useEffect(() => {
  bar.start();

  fetchData().then(() => {
    bar.complete();
  });
}, []);

🧱 Built With

  • ✅ React 17+ or 18+
  • ✅ Pure CSS transitions
  • ✅ React Context + useRef + forwardRef
  • ❌ No third-party animation libraries

📝 License

MIT © jamalofficial


🧑‍💻 Contributing

Contributions are welcome! Please open an issue or submit a PR.


🌐 Links