Progress BarGetting Started

Getting Started

Install and start using progress bars

Installation

Install the package using your preferred package manager:

pnpm add @visulima/progress-bar
bash npm install @visulima/progress-bar
bash yarn add @visulima/progress-bar
bun add @visulima/progress-bar

Basic Usage

Simple Progress Bar

import { ProgressBar } from "@visulima/progress-bar";

const bar = new ProgressBar({ total: 100 });

bar.update(25);
console.log(bar.render());
// progress [██████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 25% | ETA: 3s | 25/100

bar.update(100);
console.log(bar.render());
// progress [████████████████████████████████████████] 100% | ETA: 0s | 100/100

Custom Format

const bar = new ProgressBar(
    {
        total: 200,
        format: "{task} [{bar}] {percentage}% | {value}/{total}",
    },
    undefined,
    { task: "Downloading" },
);

bar.update(100);
console.log(bar.render());
// Downloading [████████████████████░░░░░░░░░░░░░░░░░░░░] 50% | 100/200

Different Styles

// ASCII style
const ascii = new ProgressBar({ total: 100, style: "ascii", format: "[{bar}]", width: 20 });
ascii.update(50);
console.log(ascii.render()); // [##########----------]

// Braille style with pill caps
const braille = new ProgressBar({ total: 100, style: "braille", format: "[{bar}]", width: 20 });
braille.update(50);
console.log(braille.render()); // [⢾⣿⣿⣿⣿⣿⣿⣿⣿⣿⠤⠤⠤⠤⠤⠤⠤⠤⠤⡷]

With Interactive Manager

For real-time terminal updates, use with @visulima/interactive-manager:

pnpm add @visulima/interactive-manager
import { InteractiveManager, InteractiveStreamHook } from "@visulima/interactive-manager";
import { ProgressBar } from "@visulima/progress-bar";

const stdoutHook = new InteractiveStreamHook(process.stdout);
const stderrHook = new InteractiveStreamHook(process.stderr);
const manager = new InteractiveManager(stdoutHook, stderrHook);

const bar = new ProgressBar({ total: 100 }, manager);
bar.start();

// Progress updates render automatically
for (let i = 0; i <= 100; i++) {
    bar.update(i);
    await new Promise((r) => setTimeout(r, 50));
}

bar.stop();

See Also

Support

Contribute to our work and keep us going

Community is the heart of open source. The success of our packages wouldn't be possible without the incredible contributions of users, testers, and developers who collaborate with us every day.Want to get involved? Here are some tips on how you can make a meaningful impact on our open source projects.

Ready to help us out?

Be sure to check out the package's contribution guidelines first. They'll walk you through the process on how to properly submit an issue or pull request to our repositories.

Submit a pull request

Found something to improve? Fork the repo, make your changes, and open a PR. We review every contribution and provide feedback to help you get merged.

Good first issues

Simple issues suited for people new to open source development, and often a good place to start working on a package.
View good first issues