pub struct MaterialProgress { /* private fields */ }Expand description
Material Design progress indicator component
Progress indicators inform users about the status of ongoing processes, such as loading an app, submitting a form, or saving updates. They communicate an app’s state and indicate available actions.
§Usage Examples
// Linear progress with value
ui.add(MaterialProgress::linear()
.value(0.65)
.size(Vec2::new(300.0, 6.0)));
// Circular progress with value
ui.add(MaterialProgress::circular()
.value(0.8)
.size(Vec2::splat(64.0)));
// Indeterminate linear progress (loading)
ui.add(MaterialProgress::linear()
.indeterminate(true));
// Buffered linear progress (like video loading)
ui.add(MaterialProgress::linear()
.value(0.3)
.buffer(0.6));
// Customized colors and style
ui.add(MaterialProgress::linear()
.value(0.5)
.active_color(Color32::RED)
.track_color(Color32::LIGHT_GRAY)
.track_gap(4.0)
.stop_indicator_radius(2.0));§Material Design Spec
- Linear: 4dp height (default), variable width
- Circular: 48dp diameter (default), 4dp stroke width
- Colors: Primary color for progress, secondaryContainer for track
- Animation: Smooth transitions, indeterminate animations
- Corner radius: pill-shaped for linear progress
- Track gap: 4dp between indicator and track (M3 2024)
- Stop indicator: 2dp radius dot at track end (linear determinate)
Implementations§
Source§impl MaterialProgress
impl MaterialProgress
Sourcepub fn new(variant: ProgressVariant) -> Self
pub fn new(variant: ProgressVariant) -> Self
Create a new progress indicator with the specified variant
Sourcepub fn value(self, value: f32) -> Self
pub fn value(self, value: f32) -> Self
Set the current progress value (clamped between 0.0 and max)
Sourcepub fn max(self, max: f32) -> Self
pub fn max(self, max: f32) -> Self
Set the maximum value for progress calculation (default: 1.0)
Sourcepub fn buffer(self, buffer: f32) -> Self
pub fn buffer(self, buffer: f32) -> Self
Set the buffer value for buffered progress (e.g., video buffering)
Sourcepub fn indeterminate(self, indeterminate: bool) -> Self
pub fn indeterminate(self, indeterminate: bool) -> Self
Enable or disable indeterminate progress animation
Sourcepub fn four_color_enabled(self, enabled: bool) -> Self
pub fn four_color_enabled(self, enabled: bool) -> Self
Enable or disable four-color animation for indeterminate progress
Sourcepub fn active_color(self, color: Color32) -> Self
pub fn active_color(self, color: Color32) -> Self
Set the indicator/active color (default: theme primary)
Sourcepub fn track_color(self, color: Color32) -> Self
pub fn track_color(self, color: Color32) -> Self
Set the track background color (default: theme secondaryContainer)
Sourcepub fn buffer_color(self, color: Color32) -> Self
pub fn buffer_color(self, color: Color32) -> Self
Set the buffer indicator color (default: theme primaryContainer)
Sourcepub fn border_radius(self, radius: f32) -> Self
pub fn border_radius(self, radius: f32) -> Self
Set the corner radius for linear progress (default: height / 2.0 for pill shape)
Sourcepub fn stroke_width(self, width: f32) -> Self
pub fn stroke_width(self, width: f32) -> Self
Set the stroke width for circular progress (default: 4.0)
Sourcepub fn track_gap(self, gap: f32) -> Self
pub fn track_gap(self, gap: f32) -> Self
Set the gap between indicator and track (default: 4.0, set 0 to hide)
Sourcepub fn stop_indicator_radius(self, radius: f32) -> Self
pub fn stop_indicator_radius(self, radius: f32) -> Self
Set the stop indicator dot radius for linear determinate (default: 2.0, set 0 to hide)
Sourcepub fn stop_indicator_color(self, color: Color32) -> Self
pub fn stop_indicator_color(self, color: Color32) -> Self
Set the stop indicator dot color (default: theme primary)
Sourcepub fn four_color(self, enabled: bool) -> Self
👎Deprecated: Use four_color_enabled() instead
pub fn four_color(self, enabled: bool) -> Self
Enable or disable four-color animation (deprecated, use four_color_enabled)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MaterialProgress
impl RefUnwindSafe for MaterialProgress
impl Send for MaterialProgress
impl Sync for MaterialProgress
impl Unpin for MaterialProgress
impl UnsafeUnpin for MaterialProgress
impl UnwindSafe for MaterialProgress
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.