ProgressBar
HkProgressBar is the horizontal progress track: one fill inside a rounded rail, with three status inks, three track heights, an optional caption line and a segmented mode for the bars that show how a whole is divided rather than how far a single job got.
- A single ratio inside a round tile — a score, a quota badge, an upload ring in a toolbar — is an HkProgressRing, which reads at sizes where a track would be a sliver.
- An operation with an unknown duration is announced by an HkSpinner or by the body of a HkLoadingVeil; a bar with no value already draws the indeterminate sweep, but it says nothing about what is happening.
Import
;
use *; // ProgressBar, ProgressBarStatus, ProgressBarSize, ProgressBarSegment
use *; // rsx!, VNode
Value, secondary and status
value is read against max (default 100) and clamped to 0–100%, so a caller may pass bytes, rows or minutes and let the bar do the arithmetic. secondary draws a buffered fill behind the primary one — the shape of an upload, where the light fill is what the server has confirmed. status picks the ink: loading (the default), done or error. The last stage also shows size="md" — one of the three track heights (xs, sm — the default — and md), detailed under Sizes below.
Sizes and the label line
size sets the rail's height: xs, sm (the default) and md. With showLabel a caption line sits above the track — the rounded percentage by default, or whatever label says, which is how a job's name or "12 of 20 files" gets in. Leave value unset and the track runs the indeterminate sweep instead (the last stage below).
Segments
segments switches the track to blocks: each entry is a percentage of the whole, laid left to right in the order given, with any CSS colour — including rgb(var(--x) / a) space syntax so CSS variables resolve. The entries must not sum past 100. Segmented mode ignores status and has no single value to print, so only an explicit label shows. In Rust an empty vector still selects the mode, exactly like Vue's empty array.
Accessibility
- The track exposes no ARIA role of its own: a bar that carries a number must say so in text. Use showLabel with a label of your own ("12 of 40 files") rather than relying on the fill's width.
- Do not lean on the status ink alone: done and error should also be stated in the surrounding copy or the caption, since the fill colour is the only difference.
- The indeterminate sweep says nothing about progress or duration — pair it with a short line of text saying what is running.
- The segments are decorative slices of one whole; give the bar a caption naming the total, because assistive technology cannot add up block widths.
API
Vue
Props
| Name | Type | Default | Required |
|---|---|---|---|
| value | Number | null | — |
| secondary | Number | null | — |
| max | Number | 100 | — |
| status | String as PropType<ProgressBarStatus> | "loading" | — |
| size | <code>String as PropType<"xs" | "sm" | "md"></code> | "sm" | — |
| showLabel | Boolean | false | — |
| label | String | undefined | — |
| segments | Array as PropType<HProgressBarSegment[]> | undefined | — |
| overValue | Number | null | — |
| overspendLabel | String | undefined | — |
| overspendTone | String as PropType<OverspendTone> | "muted" | — |
Rust
Props — ProgressBar
| Prop | Type | Default | Description |
|---|---|---|---|
| value | Option<f64> | None | Determinate fill percentage input, scaled by max. |
| secondary | Option<f64> | None | Secondary (buffered) fill behind the primary one. |
| max | f64 | 100.0 | The value/secondary scale denominator (default 100). |
| status | ProgressBarStatus | ProgressBarStatus::Loading | Fill ink. |
| size | ProgressBarSize | ProgressBarSize::Sm | Track size (data-size). |
| show_label | bool | false | Render the label line above the track. |
| label | Option<String> | None | Explicit label text; when empty the rounded percentage shows (and segments mode shows nothing without it). |
| segments | Option<Vec<ProgressBarSegment>> | None | Segmented mode: when Some (an empty vec included) the track renders one block per segment instead of the value/secondary fills. |
| over_value | Option<f64> | None | Overspend amount, in the same unit as value/max: how far the measured quantity runs past max. |
| overspend_label | Option<String> | None | Caption for the overspend stretch ("超支 0.8 度"). |
| overspend_tone | ProgressBarOverspendTone | ProgressBarOverspendTone::Muted | Overspend block tone; see ProgressBarOverspendTone. |
Related components
- HkProgressRing — the same ratio as a circular arc, for badges and compact tiles.
- HkSpinner — the inline busy indicator for work that has no measurable width.
- HkLoadingVeil — a blocking overlay when a whole page is waiting.
- HkSkeleton — the placeholder shape of the content that is still loading.
- HkEmptyState — what a region shows when the load finished with nothing in it.