with_width

Function with_width 

Source
pub fn with_width(w: i32) -> ProgressOption
Expand description

Sets the total width of the progress bar in characters.

This width includes both the visual bar and the percentage text (if shown). You can also modify the width later using the width field, which is useful for responsive layouts that need to adjust to terminal size changes.

§Arguments

  • w - Width in characters (must be positive)

§Examples

use bubbletea_widgets::progress::{new, with_width};

// Narrow progress bar for compact spaces
let narrow = new(&[with_width(20)]);

// Wide progress bar for detailed view
let wide = new(&[with_width(80)]);

// Responsive width (can be changed later)
let mut responsive = new(&[with_width(40)]);
responsive.width = 60; // Adjust based on terminal size