ProgressBarOptions
The ProgressBarOptions interface defines the visual configuration for a progress bar in ts-better-console. It controls the bar length, display symbols, animation style, and per-state colors.
Type Definition
The ProgressBarOptions interface includes the following properties:
loadedSymbol: Character used for the filled portion of the bar. Defaults to"█".bufferedSymbol: Character used for the buffered portion. Defaults to"▒".emptySymbol: Character used for the empty portion. Defaults to"-".length: The bar width in characters, or"full-width"to fill the terminal. Defaults to40. Minimum is10.animation: AProgressAnimationOptionsobject to enable a rainbow animation (see below), orfalseto disable. Defaults tofalse.color: AProgressBarStateColorobject to customize colors for each bar segment and state.position: Where to render the bar —"inline","top", or"bottom". Defaults to"inline".
interface ProgressBarOptions {
loadedSymbol?: string;
bufferedSymbol?: string;
emptySymbol?: string;
length?: number | "full-width";
animation?: false | ProgressAnimationOptions;
color?: ProgressBarStateColor;
position?: FixedPosition;
}
ProgressAnimationOptions
When animation is not false, pass a ProgressAnimationOptions object to configure the animation:
type:"rainbow"— a scrolling parallax wave using the 6-color 4-bit palette; or"rainbow-smooth"— a full-spectrum 8-bit gradient.speed(optional): Animation interval in milliseconds. Defaults to80.size(optional): Wave size of the animation. Defaults to0.
interface ProgressAnimationOptions {
type: "rainbow" | "rainbow-smooth";
speed?: number; // ms, default 80
size?: number; // wave size, default 0
}
Usage
Pass ProgressBarOptions via the bar property of ProgressOptions:
import { Progress } from "ts-better-console";
const bar = new Progress("Building", 100, {bar: {});loadedSymbol: "#",},
emptySymbol: ".",
length: 50,
animation: { type: "rainbow" },
color: {loaded: "cyan",},
completed: "green",
Want to support this project?
If you find ts-better-console useful and want to support its development, consider starring the GitHub repository or buying me a coffee! Your support helps me dedicate more time to improving the library and adding new features.
Want to contribute to this project?
Contributions are welcome! If you're interested in improving the library, fixing bugs, or adding new features, feel free to check out the GitHub repository and submit a pull request. Whether you're a seasoned developer or new to open source, your contributions can make a difference!