@jasonscheirer/native-progress-bar
v1.1.2
Published
This module allows your Electron app to display native dialogs with progress bars in them on Windows, macOS, and Linux.
Maintainers
Readme
native-progress-bar
This module allows your Electron app to display native dialogs with progress bars in them on Windows, macOS, and Linux.
It has no runtime dependencies other than bindings and creates a ~85KB Node addon.
To see various examples for progress bars, check out test/src/progress-bars.js.
Screenshots




Application required (macOS)
On macOS, the module only works in Node.js environments that run within a proper application (like Electron).
It therefore does not run in simple Node.js scripts that you might execute with node myscript.js.
API
import { ProgressBar } from "native-progress-bar"
let progressBar, interval;
// All arguments are optional
progressBar = new ProgressBar({
// Window title
title: "Running disk operation",
// Message, shown above the progress bar
message: "Running format C:",
// Initial progress value
progress: 0,
// Can be "hud", "utility", or "default". Only effective on macOS and Linux.
style: "hud"
// Zero or more buttons
buttons: [{
label: "Cancel",
click: (progressBar) => {
console.log("Cancel button clicked");
progressBar.close();
}
}],
// A function called when the dialog is closed. Useful to cleanup intervals.
onClose: () => {
clearInterval(interval);
},
});
interval = setInterval(() => {
if (progressBar.progress >= 100) {
clearInterval(interval);
// You can dynamically change buttons
progressBar.buttons = [{
label: "Done",
click: (progressBar) => {
console.log("Done button clicked");
progressBar.close();
}
}]
return
}
progressBar.progress += 1;
}, 200);What about Linux?
Linux is supported using GTK4 and Libadwaita. To build from source, install the development packages:
- Fedora / RHEL:
sudo dnf install gtk4-devel libadwaita-devel - Ubuntu / Debian:
sudo apt install libgtk-4-dev libadwaita-1-dev
Prebuilt binaries are included for common Electron/Node ABIs, but if your ABI is not covered, npm install will compile the addon automatically.
