package progress

  1. Overview
  2. Docs
type t

The type of progress bar style specifications.

val ascii : t

The style used by bar ~style:`ASCII (which is the default). Generates bars of the form [######---].

val utf8 : t

utf8 is the style used by bar ~style:`UTF8. Uses the UTF-8 block element characters (U+2588U+258F) for progress stages, and a box-drawing character (U+2502) for delimiters.

Custom styles

val v : ?delims:(string * string) -> ?color:Color.t -> ?color_empty:Color.t -> string list -> t

v stages is a bar that uses the given string stages to render progress. The first stage is interpreted as a "full" segment, with subsequent stages denoting progressively less-full segments until a final "empty" stage (which is implicitly a space if only one stage is provided).

The optional parameters are as follows:

  • ?delims: a pair of left and right delimiters used to wrap the body of the progress bar;
  • ?color: the color of non-empty segments (including the in-progress one);
  • ?color_empty: the color of empty segments.


  • v [ "#" ] renders like "####### ";
  • v [ "="; ">"; " " ] renders like "======> ";
  • v [ "4"; "3"; "2"; "1"; "0" ] renders like "444444410000";
  • ... see examples/ in the source repository for more.


Each segment of a rendering progress bar is in one of three states: full, empty or in-progress. At any given time, either the bar is entirely full or or there is exactly one in-progress segment. Given the style v [s1; s2; ... sN], these states are rendered as follows:

  • full: rendered as s1;
  • empty: rendered as sN if N >= 1, otherwise ' ';
  • in-progress: if N <= 1, then equivalent to the empty state. Otherwise, the intermediate stages s2, s3, ... s{N-1} denote decreasing progress. For example, if there are four intermediate stages (N = 6) then s2 is used for progress in the range [0, 25%), s3 for [25%, 50%) etc.

For the progress bar to render within a fixed size, the user must ensure that each of the stages must have the same rendered width.


val with_color : Color.t -> t -> t
val with_empty_color : Color.t -> t -> t
val with_delims : (string * string) option -> t -> t
val with_stages : string list -> t -> t