new

Function new 

Source
pub fn new(opts: &[ProgressOption]) -> Model
Expand description

Creates a new progress bar with the specified configuration options.

This function initializes a progress bar with sensible defaults and applies any provided options to customize its appearance and behavior. The progress bar starts at 0% and is ready for animation and display.

§Arguments

  • opts - A slice of ProgressOption values to configure the progress bar

§Default Configuration

  • Width: 40 characters
  • Fill character: ‘█’ (full block)
  • Empty character: ‘░’ (light shade)
  • Fill color: “#7571F9” (purple)
  • Empty color: “#606060” (gray)
  • Percentage: Shown by default
  • Animation: Spring physics with frequency=18.0, damping=1.0

§Examples

§Basic Progress Bar

use bubbletea_widgets::progress::new;

// Create with all defaults
let progress = new(&[]);
assert_eq!(progress.width, 40);

§Customized Progress Bar

use bubbletea_widgets::progress::*;

let progress = new(&[
    with_width(60),
    with_solid_fill("#e74c3c".to_string()),
    without_percentage(),
    with_spring_options(25.0, 0.8),
]);

§Gradient Progress Bar

use bubbletea_widgets::progress::*;

let gradient_progress = new(&[
    with_gradient("#667eea".to_string(), "#764ba2".to_string()),
    with_width(50),
]);