1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
use *;
use component_doc;
use inject_style;
use progress_bar_styles;
use ProgressBarColor;
/// `ProgressBar` shows measurable progress toward a known total — uploads, imports, or wizard steps.
///
/// Bind `value` and optional `max` (default 1) and pick a semantic `color` when status matters. **`value` is on a 0–`max` scale** — unlike [`ProgressCircle`], which uses 0–100 percent. Indeterminate mode is not supported; for unknown duration use [`Spinner`](crate::Spinner) or [`LoadingBar`](crate::LoadingBar). Pair with visible status text when the percentage is critical for accessibility.
///
/// # When to use
///
/// - File uploads, imports, or multi-step flows with known totals
/// - Inline progress beside labels in lists or cards
/// - Non-zero-based scales via custom `max` (e.g. step 3 of 5)
///
/// Prefer [`ProgressCircle`](crate::ProgressCircle) for compact circular metrics. Prefer [`Spinner`](crate::Spinner) when duration is unknown.
///
/// # Examples
///
/// ## Default progress bar
/// A brand-colored bar at 50% shows halfway completion for uploads, imports, or stepped flows.
/// <!-- preview -->
/// ```rust
/// use crate::ProgressBar;
/// view! {
/// <div data-testid="progress-bar-preview" style="width: 100%; max-width: 400px; padding: 12px 0;">
/// <ProgressBar value=Signal::from(0.5) />
/// </div>
/// }
/// ```
///
/// ## Semantic colors
/// Color presets communicate success, warning, or error without relying on color alone — pair with text for critical states.
/// <!-- preview -->
/// ```rust
/// use crate::{Flex, FlexGap, ProgressBar, ProgressBarColor};
/// view! {
/// <div data-testid="progress-bar-colors" style="width: 100%; max-width: 400px; padding: 12px 0;">
/// <Flex vertical=true gap=FlexGap::Small>
/// <ProgressBar value=Signal::from(0.75) color=Signal::from(ProgressBarColor::Success) />
/// <ProgressBar value=Signal::from(0.5) color=Signal::from(ProgressBarColor::Warning) />
/// <ProgressBar value=Signal::from(0.25) color=Signal::from(ProgressBarColor::Error) />
/// </Flex>
/// </div>
/// }
/// ```
///
/// ## Custom max
/// Set `max` when the scale is not 0–1 (e.g. steps in a wizard).
/// <!-- preview -->
/// ```rust
/// use crate::ProgressBar;
/// view! {
/// <div data-testid="progress-bar-max" style="width: 100%; max-width: 400px; padding: 12px 0;">
/// <ProgressBar value=Signal::from(3.0) max=Signal::from(5.0) />
/// </div>
/// }
/// ```
///
/// ## Low and high values
/// Values clamp to the track ends — useful for near-complete or just-started states.
/// <!-- preview -->
/// ```rust
/// use crate::{Flex, FlexGap, ProgressBar};
/// view! {
/// <div data-testid="progress-bar-extremes" style="width: 100%; max-width: 400px; padding: 12px 0;">
/// <Flex vertical=true gap=FlexGap::Small>
/// <ProgressBar value=Signal::from(0.05) />
/// <ProgressBar value=Signal::from(0.95) />
/// </Flex>
/// </div>
/// }
/// ```
///
/// ## Progress circle
/// Circular indicator for compact layouts or dashboard tiles. `value` is a percentage 0–100.
/// <!-- preview -->
/// ```rust
/// use crate::ProgressCircle;
/// view! {
/// <div data-testid="progress-circle-preview">
/// <ProgressCircle value=65.0 />
/// </div>
/// }
/// ```
///
/// ## Progress circle colors
/// Semantic color presets for dashboard KPI tiles.
/// <!-- preview -->
/// ```rust
/// use crate::{Flex, FlexGap, ProgressCircle, ProgressCircleColor};
/// view! {
/// <div data-testid="progress-circle-colors">
/// <Flex gap=FlexGap::Large>
/// <ProgressCircle value=80.0 color=ProgressCircleColor::Success />
/// <ProgressCircle value=45.0 color=ProgressCircleColor::Warning />
/// </Flex>
/// </div>
/// }
/// ```
///
/// ## Progress circle size
/// Adjust diameter with the `size` prop (CSS length).
/// <!-- preview -->
/// ```rust
/// use crate::ProgressCircle;
/// view! {
/// <div data-testid="progress-circle-size">
/// <ProgressCircle value=50.0 size="80px" />
/// </div>
/// }
/// ```
]
max: ,
/// Semantic color preset (`Brand`, `Success`, `Warning`, `Error`).
color: ,
)