A C library for rendering progress bars and spinners in the terminal.
loading-screen-lib.mp4
This library provides a simple API for displaying progress bars and spinners in CLI applications. It supports multiple visual styles (blocks, unicode, braille, spinner), ANSI colors, and customizable positioning and timing. You control width, labels, animation speed, and whether to show percentage text.
To learn how to write clean, reusable C libraries with clear APIs. Most progress bar libraries are wrappers or language-specific; this one is native C with support for C++ via extern "C".
- C99 (core library)
- CMake (optional build system)
- ANSI terminal escape codes (color and cursor control)
Clone and build with CMake:
git clone https://github.com/sanskarsontakke/loading-screen-c-lib.git
cd loading-screen-c-lib
mkdir build && cd build
cmake ..
make
sudo make installOr build with Make:
git clone https://github.com/sanskarsontakke/loading-screen-c-lib.git
cd loading-screen-c-lib
make
./loading_demoInclude the header and call three functions: ls_init() to set up the terminal, ls_display() to render a progress bar with a config struct, and ls_cleanup() to restore the terminal state. The config struct lets you pick a style (blocks, smooth Unicode, Braille dots, spinner), a color, width, position, and other display options. The library uses ANSI escape codes for cursor positioning and color, so it works on any modern terminal.
| Type | Appearance | Description |
|---|---|---|
LS_TYPE_BLOCKS |
[#### ] |
Classic block style |
LS_TYPE_EQUALS |
[==== ] |
Equals signs |
LS_TYPE_SMOOTH |
[████ ] |
Unicode smooth blocks |
LS_TYPE_BRAILLE |
[⣿⣿⣿ ] |
Braille dots |
LS_TYPE_SPINNER |
/ |
Indeterminate spinner |
#include "loading_screen.h"
int main() {
ls_init();
ls_config_t config = ls_get_default_config();
config.label = "Downloading";
config.type = LS_TYPE_SMOOTH;
config.color = LS_COLOR_GREEN;
ls_display(&config, 100);
ls_cleanup();
return 0;
}typedef struct {
ls_type_t type; // Bar style
ls_color_t color; // ANSI color
int width; // Bar width
int x, y; // Cursor position (0 = current)
int delay_ms; // Animation speed
int show_percentage; // Show % text
const char* label; // Prefix label
int use_arrow; // Add '>' to progress
int clear_on_finish; // Clear bar after done
int stay_on_line; // Keep bar when done
} ls_config_t;Working library. Tested on Linux, macOS, and Windows (via Virtual Terminal Processing).
MIT © 2026 Sanskar Sontakke