Progress
Layer: atom · Path:
src/atoms/progress.rs· Exports:progress::Progress
A determinate progress indicator (fraction in 0..=1), rendered as a continuous bar, a stepped (segmented) bar, or a circular ring. Modeled on shadcn Progress / Unity Progress Bar. For indeterminate loading use Spinner.
Design
-
Purpose / when to use — show known completion progress. Use the ring for compact/inline placement, steps for discrete stages, the bar for general progress.
-
Anatomy
- Bar (continuous): pill track (
muted) + aprimaryfill rect from the left, width =track × fraction. - Bar (stepped):
nequal pills withSPACE_1gaps; the firstround(fraction × n)areprimary, the restmuted. - Ring: a
mutedcircle stroke + aprimaryarc sweepingfraction × 360°from 12 o’clock.
- Bar (continuous): pill track (
-
Variants / sizes / states
Builder Render new(fraction)continuous bar, SPACE_2tall, full width.steps(n)nsegments (≥1).circular()ring at CONTROL_LG(38px) diameter.circular_size(d)ring at diameter dNo interactive states (sense is
hover). -
Tokens consumed —
theme.muted(track),theme.primary(fill/arc),core::SPACE_2(bar height / circular thickness viaSPACE_1),core::SPACE_1(segment gap & ring thickness),core::CONTROL_LG(default ring size). -
Accessibility — bare hover
Response; nowidget_info.
API
| Signature | Effect |
|---|---|
Progress::new(fraction: f32) -> Self | Construct; fraction clamped to 0..=1. |
.steps(n: usize) -> Self | Render n discrete segments (min 1). |
.circular(self) -> Self | Render as a ring at the default diameter. |
.circular_size(size: f32) -> Self | Render as a ring at size diameter. |
.show(self, ui: &mut Ui) -> Response | Paint and return the hover Response. |
Usage
#![allow(unused)]
fn main() {
use ouroboros_ui::atoms::Progress;
Progress::new(0.42).show(ui);
}
#![allow(unused)]
fn main() {
use ouroboros_ui::atoms::Progress;
Progress::new(0.6).steps(5).show(ui); // stepped bar
Progress::new(0.6).circular().show(ui); // ring
}
Composition
Atom: paints rects/strokes/arc directly. Composes no other atoms.
Notes
fractionis clamped on construction — out-of-range values are safe.- The bar variant takes
ui.available_width(); the ring is fixed-size. - This is determinate only; there is no indeterminate bar — use
Spinner.