Skip to content

hamza-siddiq/ProgressBar

Repository files navigation

ProgressBar

A beautiful, production-ready progress bar library for .NET console applications.

Version .NET License

Features

  • 6 Beautiful Themes - Default, Ocean, Sunset, Forest, Neon, Minimal
  • Smooth Animations - Fractional block characters for buttery-smooth progress
  • Gradient Colors - True-color gradient across the progress bar
  • Rich Information Display - Percentage, ETA, speed, elapsed time, count
  • Spinner - Indeterminate progress with 6 animation styles
  • Fluent API - Chainable configuration for easy customization
  • Thread-Safe - Safe to use from multiple threads
  • Responsive - Auto-detects terminal width
  • Production-Ready - IDisposable, validation, graceful degradation

Quick Start

using ProgressBar;

// Simple usage
using var bar = new ProgressBar(100);
for (int i = 0; i < 100; i++)
{
    bar.Tick();
}

Themes

var options = new ProgressBarOptions()
    .WithTheme(ProgressBarTheme.Ocean);

using var bar = new ProgressBar(100, options);

Available themes:

Theme Description
Default Classic green on gray
Ocean Blue/cyan gradient
Sunset Warm orange/pink
Forest Earth green tones
Neon Cyberpunk purple/cyan
Minimal Clean monochrome

Configuration

var options = new ProgressBarOptions()
    .WithTheme(ProgressBarTheme.Sunset)
    .WithWidth(50)
    .WithBarChar("█", "░")
    .WithPercentage()
    .WithETA()
    .WithSpeed()
    .WithElapsedTime()
    .WithCount()
    .WithMessage("Processing files...");

using var bar = new ProgressBar(1000, options);

Spinner

For indeterminate progress:

using var spinner = new Spinner(SpinnerStyle.Dots, "Loading...");
spinner.Start();

// Do work...
spinner.UpdateMessage("Processing...");

// Done
spinner.Stop("✓ Complete!");

Available spinner styles: Dots, Line, Circle, Bounce, Arrow, Moon

API Reference

ProgressBar

Method Description
Tick() Advance by 1
Tick(long n) Advance by n
SetProgress(long value) Set absolute progress
SetMessage(string? msg) Update display message
Complete() Mark as complete
Complete(string msg, string color) Complete with status
Fail() Mark as failed
Hide() / Show() Toggle visibility

ProgressBarOptions

Method Description
WithWidth(int) Bar width (default: 40)
WithTheme(ProgressBarTheme) Color theme
WithBarChar(filled, empty) Bar characters
WithPercentage(bool) Show percentage
WithETA(bool) Show estimated time
WithSpeed(bool) Show items/sec
WithElapsedTime(bool) Show elapsed time
WithCount(bool) Show current/total
WithMessage(string?) Custom message
WithAutoComplete(bool) Auto-complete on dispose

Advanced Usage

Dynamic Messages

using var bar = new ProgressBar(100, new ProgressBarOptions()
    .WithMessage("Initializing..."));

for (int i = 0; i < 100; i++)
{
    if (i == 25) bar.SetMessage("Processing...");
    if (i == 75) bar.SetMessage("Finalizing...");
    bar.Tick();
}

Completion Status

using var bar = new ProgressBar(50);
try
{
    // Do work
    bar.Complete("✓ SUCCESS", "\u001b[38;5;46m");
}
catch
{
    bar.Fail();
}

Thread-Safe Usage

var bar = new ProgressBar(1000);

Parallel.For(0, 1000, i =>
{
    // Process item
    bar.Tick();
});

Installation

dotnet add package ProgressBar

Or clone the repository:

git clone https://github.com/hamza-siddiq/ProgressBar.git

Requirements

  • .NET 8.0 or later
  • Terminal with ANSI color support

License

MIT

About

A progress bar in C#

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages