loaders.zig

loader zig Documentation Zig Version GitHub stars GitHub issues GitHub pull requests GitHub last commit License CI Supported Platforms Release Latest Release Sponsor GitHub Sponsors

A fast, high-performance terminal loading indicator and progress bar library for Zig.

Documentation | API Reference | Quick Start | Source

loaders.zig is a production-oriented Zig library for animated spinners, progress bars, and multi-progress terminal UIs. It is designed for low overhead, clean output, and cross-platform terminal behavior on Linux, Windows, and macOS.

[!NOTE] This project is still evolving, but the current API is built to be practical for real CLI tools and long-running terminal workflows.

⭐ If you find loaders.zig useful, consider starring the repository.


Table of Contents (click to expand) - [Prerequisites](#prerequisites) - [Supported Platforms](#supported-platforms) - [Features](#features) - [Installation](#installation) - [Option A: Stable Release](#option-a--stable-release-recommended-for-production) - [Option B: Nightly / Beta](#option-b--nightly--beta-latest-main-branch) - [Option C: Build from Source](#option-c--build-from-source) - [Quick Start](#quick-start) - [Usage Examples](#usage-examples) - [Configuration](#configuration) - [Documentation](#documentation) - [Building](#building) - [Contributing](#contributing) - [License](#license) - [Links](#links)

Features (click to expand) | Feature | Description | Documentation | |---------|-------------|---------------| | **Simple & Fluent API** | Add progress indicators in just a few lines. | [Guide](https://muhammad-fiaz.github.io/loaders.zig/guide/getting-started) | | **Progress Bars** | Animated single-bar progress with percentage, ETA, and rate display. | [Guide](https://muhammad-fiaz.github.io/loaders.zig/guide/progress-bar) | | **Spinners** | Background-threaded terminal spinners for non-blocking work. | [Guide](https://muhammad-fiaz.github.io/loaders.zig/guide/spinner) | | **Multi Progress** | Render multiple concurrent bars or spinners together. | [Guide](https://muhammad-fiaz.github.io/loaders.zig/guide/multi-progress) | | **Styling** | Configure brackets, fills, colors, and suffixes. | [Guide](https://muhammad-fiaz.github.io/loaders.zig/guide/styling) | | **Themes** | Use built-in visual presets for bars and spinners. | [Guide](https://muhammad-fiaz.github.io/loaders.zig/guide/themes) | | **ANSI Colors** | Support for 16-color ANSI, 256-color, and RGB output. | [Guide](https://muhammad-fiaz.github.io/loaders.zig/guide/colors) | | **Cross-Platform TTY Handling** | Detects terminal capabilities on Windows and POSIX systems. | [Guide](https://muhammad-fiaz.github.io/loaders.zig/guide/advanced) | | **No-Color Friendly** | Respects `NO_COLOR` and redirected output. | [Guide](https://muhammad-fiaz.github.io/loaders.zig/guide/advanced) | | **Stack-Friendly** | Designed to work well in small CLI tools and longer-running programs. | [API](https://muhammad-fiaz.github.io/loaders.zig/api/) |

Prerequisites & Supported Platforms (click to expand)
## Prerequisites Before using `loaders.zig`, ensure you have: | Requirement | Version | Notes | |-------------|---------|-------| | **Zig** | 0.16.0 | Install from [ziglang.org](https://ziglang.org/download/) | | **Operating System** | Windows, Linux, macOS | Cross-platform support | | **Terminal** | Any modern terminal | For color and cursor control | --- ## Supported Platforms | Platform | Status | |----------|--------| | **Windows** | Full support | | **Linux** | Full support | | **macOS** | Full support | --- ### Color Support | Terminal | Support | |----------|---------| | **Windows Terminal** | Native ANSI | | **PowerShell / CMD** | Supported with terminal capabilities | | **iTerm2 / Terminal.app** | Native | | **GNOME Terminal / Konsole** | Native | | **VS Code Terminal** | Native |

Installation

Pin to a specific tagged release for reproducible builds:

zig fetch --save https://github.com/muhammad-fiaz/loaders.zig/archive/refs/tags/0.0.1.tar.gz

This automatically adds the dependency to your build.zig.zon:

.dependencies = .{
    .loaders = .{
        .url = "https://github.com/muhammad-fiaz/loaders.zig/archive/refs/tags/0.0.1.tar.gz",
        .hash = "...", // auto-filled by zig fetch --save
    },
},

Option B — Nightly / Beta (Latest Main Branch)

Use the latest unreleased code from main. This tracks HEAD and may include breaking changes:

zig fetch --save git+https://github.com/muhammad-fiaz/loaders.zig.git

This adds a git dependency to your build.zig.zon:

.dependencies = .{
    .loaders = .{
        .url = "git+https://github.com/muhammad-fiaz/loaders.zig.git",
        .hash = "...", // auto-filled by zig fetch --save
    },
},

[!TIP] Use zig fetch --save (with URL) for the automatic flow. It resolves the hash and writes it into build.zig.zon for you.

Option C — Build from Source

git clone https://github.com/muhammad-fiaz/loaders.zig.git
cd loaders.zig
zig build

Quick Start

Progress Bar

const std = @import("std");
const loaders = @import("loaders");

pub fn main(init: std.process.Init) !void {
    const io = init.io;
    var bar = loaders.Bar.init(io, .{
        .label = "Processing",
        .total = 100,
        .show_percent = true,
        .show_elapsed = true,
    });
    defer bar.done();

    for (0..100) |i| {
        bar.setCompleted(i + 1);
        bar.render();
        try io.sleep(std.Io.Duration.fromMilliseconds(30), .awake);
    }
}

Spinner

const std = @import("std");
const loaders = @import("loaders");

pub fn main(init: std.process.Init) !void {
    const io = init.io;
    const sp = try loaders.Spinner.start(io, .{
        .text = "Syncing local database...",
        .style = loaders.SpinnerStyle.dots,
    });

    try io.sleep(std.Io.Duration.fromSeconds(2), .awake);
    sp.succeed(io, "Database synchronized successfully!");
}

Multi Progress

const std = @import("std");
const loaders = @import("loaders");

pub fn main(init: std.process.Init) !void {
    const io = init.io;
    var mb = loaders.MultiBar.init(io, std.Io.File.stderr(), null, .{});

    const a = mb.addBar(.{ .label = "Asset A", .total = 100 });
    const b = mb.addBar(.{ .label = "Asset B", .total = 100 });

    for (0..100) |i| {
        a.setCompleted(i + 1);
        b.setCompleted(i + 1);
        mb.render();
        try io.sleep(std.Io.Duration.fromMilliseconds(20), .awake);
    }

    mb.done();
}

Usage Examples


Configuration

The core options are available through BarOptions and SpinnerOptions in the API reference.

  • label, text, and prefix for user-facing messages
  • total, show_percent, show_elapsed, show_eta, and show_rate for progress details
  • style, color_enabled, and custom bracket/fill fields for output control
  • file and term for stream selection and terminal capability detection

See the full API at API Reference.


Documentation

Online Documentation

Full documentation is available at: https://muhammad-fiaz.github.io/loaders.zig/

Generating Local Documentation

cd docs
bun install
bun run build

The output is written to docs/.vitepress/dist/.


Building

zig build test
zig build examples
zig fmt --check build.zig src/ examples/

Contributing

Contributions are welcome! Please read the Contributing Guide for details on how to get started, run tests, and submit pull requests.


License

MIT License - see LICENSE for details.


  • Documentation: https://muhammad-fiaz.github.io/loaders.zig/
  • API Reference: https://muhammad-fiaz.github.io/loaders.zig/api/
  • Guide: https://muhammad-fiaz.github.io/loaders.zig/guide/
  • Repository: https://github.com/muhammad-fiaz/loaders.zig
  • Issues: https://github.com/muhammad-fiaz/loaders.zig/issues