Progress Bars
On Windows, you can use a taskbar button to display a progress bar.
On macOS, the progress bar will be displayed as a part of the dock icon.
All three cases are covered by the same API - the
method available on an instance of
BrowserWindow
. To indicate your progress, call this method with a number
between and 1
. For example, if you have a long-running task that is
currently at 63% towards completion, you would call it as
.
Setting the parameter to negative values (e.g. -1
) will remove the progress
bar. Setting it to a value greater than will indicate an indeterminate progress bar
in Windows or clamp to 100% in other operating systems. An indeterminate progress bar
remains active but does not show an actual percentage, and is used for situations when
you do not know how long an operation will take to complete.
Example
In this example, we add a progress bar to the main window that increments over time using Node.js timers.
After launching the Electron application, the dock (macOS) or taskbar (Windows, Unity) should show a progress bar that starts at zero and progresses through 100% to completion. It should then show indeterminate (Windows) or pin to 100% (other operating systems) briefly and then loop.
For macOS, the progress bar will also be indicated for your application when using Mission Control: