pub struct Steps { /* private fields */ }Expand description
A stepped progress indicator.
// Release pipeline: 4 of 6 steps complete, step 5 running.
ui.add(Steps::new(6).current(4));
// Migration failed on step 3.
ui.add(Steps::new(5).current(2).errored(true));
// Onboarding — numbered circles.
ui.add(Steps::new(5).current(2).style(StepsStyle::Numbered));
// Setup wizard — numbered circles with labels and an "in progress"
// hint under the active step.
ui.add(
Steps::labeled(["Account", "Workspace", "Billing", "Integrations", "Review"])
.style(StepsStyle::Numbered)
.current(2)
.active_sublabel("In progress"),
);
// Horizontal labeled strip — a progress bar with stage names.
ui.add(
Steps::labeled(["Plan", "Build", "Test", "Deploy"])
.current(2),
);
// Vertical wizard sidebar.
ui.add(
Steps::labeled(["Plan", "Design", "Build", "Test", "Deploy"])
.current(2)
.vertical(),
);Implementations§
Source§impl Steps
impl Steps
Sourcepub fn new(total: usize) -> Self
pub fn new(total: usize) -> Self
Create a cells-style stepped bar with total steps (clamped to at
least 1), all pending.
Sourcepub fn labeled(labels: impl IntoIterator<Item = impl Into<String>>) -> Self
pub fn labeled(labels: impl IntoIterator<Item = impl Into<String>>) -> Self
Create a StepsStyle::Labeled widget whose step count and labels
come from labels. Horizontal by default; call Self::vertical
for a wizard-sidebar layout. All steps start pending; add
.current(n) to mark the first n as done.
Pair with .style(StepsStyle::Numbered) to render the same labels
as captions under numbered circles, an onboarding stepper layout.
Sourcepub fn vertical(self) -> Self
pub fn vertical(self) -> Self
Render labeled cells stacked vertically. Only affects
StepsStyle::Labeled.
Sourcepub fn horizontal(self) -> Self
pub fn horizontal(self) -> Self
Render labeled cells arranged horizontally (the default for
Steps::labeled). Provided as the explicit counterpart to
Self::vertical.
Sourcepub fn current(self, current: usize) -> Self
pub fn current(self, current: usize) -> Self
Set how many steps are complete. Clamped to 0..=total.
Sourcepub fn errored(self, errored: bool) -> Self
pub fn errored(self, errored: bool) -> Self
When true, paint the step at current as errored instead of
active. No effect when current == total (nothing to error on).
Sourcepub fn style(self, style: StepsStyle) -> Self
pub fn style(self, style: StepsStyle) -> Self
Pick the visual style. Default: StepsStyle::Cells.
Sourcepub fn active_sublabel(self, text: impl Into<String>) -> Self
pub fn active_sublabel(self, text: impl Into<String>) -> Self
Caption shown directly under the active step’s label (numbered style with labels only). Useful for stepper-style “In progress” or “Action required” hints. No effect on other styles or when the pipeline has no active step.
Sourcepub fn height(self, height: f32) -> Self
pub fn height(self, height: f32) -> Self
Override the cell height (cells style) or dot diameter (numbered style). Defaults: 6 for cells, 22 for numbered.
Sourcepub fn desired_width(self, width: f32) -> Self
pub fn desired_width(self, width: f32) -> Self
Override the total width. Defaults to ui.available_width().