ProgressBar

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

tsx
1
import { HkProgressBar } from "@celestia-island/hikari";
rust
1
2
use hikari_components::*;          // ProgressBar, ProgressBarStatus, ProgressBarSize, ProgressBarSegment
use hikari_components::prelude::*; // 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).

Uploading photos
30%

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.

Storage by account

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

NameTypeDefaultRequired
valueNumbernull—
secondaryNumbernull—
maxNumber100—
statusString as PropType<ProgressBarStatus>"loading"—
size<code>String as PropType<"xs" | "sm" | "md"></code>"sm"—
showLabelBooleanfalse—
labelStringundefined—
segmentsArray as PropType<HProgressBarSegment[]>undefined—
overValueNumbernull—
overspendLabelStringundefined—
overspendToneString as PropType<OverspendTone>"muted"—

Rust

Props — ProgressBar

PropTypeDefaultDescription
valueOption<f64>NoneDeterminate fill percentage input, scaled by max.
secondaryOption<f64>NoneSecondary (buffered) fill behind the primary one.
maxf64100.0The value/secondary scale denominator (default 100).
statusProgressBarStatusProgressBarStatus::LoadingFill ink.
sizeProgressBarSizeProgressBarSize::SmTrack size (data-size).
show_labelboolfalseRender the label line above the track.
labelOption<String>NoneExplicit label text; when empty the rounded percentage shows (and segments mode shows nothing without it).
segmentsOption<Vec<ProgressBarSegment>>NoneSegmented mode: when Some (an empty vec included) the track renders one block per segment instead of the value/secondary fills.
over_valueOption<f64>NoneOverspend amount, in the same unit as value/max: how far the measured quantity runs past max.
overspend_labelOption<String>NoneCaption for the overspend stretch ("超支 0.8 度").
overspend_toneProgressBarOverspendToneProgressBarOverspendTone::MutedOverspend 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.