Skip to content

Progress

alikit:progress presents determinate or indeterminate work. A determinate bar publishes role Progress, a visible percentage, and a numeric value/minimum/maximum. An indeterminate bar publishes no numeric value. The application owns the value, range, and indeterminate phase.

Native progress window showing four determinate downloads at 0, 25, 60, and 100 percent plus an indeterminate Loading workspace bar
Native SDL_GPU capture of examples/progress at Alicorn 47c9d4a. The example theme supplies the track and teal fill roles; the value text and segment geometry carry the state.
Interactive WebGPU preview is a later catalog step. The capture is the real native component; the bar is not recreated in JavaScript. The capture predates the parts examples; re-capture is pending.
LayerResponsibility
AlicornLayout, semantic surfaces, Progress role, numeric range, retained paint, reduced-motion preference, and paint-only motion.
progressTrack, fill, label, and value parts; clamping; percentage formatting; indeterminate geometry; optional pulse declaration; namespaced surface recipe.
ApplicationValue/range, indeterminate phase, and any animation loop that advances the phase.

The component has no timer, animation lifecycle, or application value. State holds diagnostic values from the most recent description: resolved fraction, phase, reduced-motion decision, and segment geometry.

Files: progress/progress.odin, progress/progress_test.odin, examples/progress/main.odin, examples/progress/theme.json.

import alicorn "alicorn:runtime"
import ui "alicorn:ui"
import progress "alikit:progress"
App :: struct {
upload: progress.State,
value: f64,
}
render :: proc(app: ^App, ctx: ^ui.UI) {
progress.progress(
ctx,
&app.upload,
app.value, 0, 100,
progress.Options{accessible_label="Upload progress", width=320},
key=alicorn.key_string("upload"),
instance_id=1,
)
}

No init or destroy is required; the component allocates nothing. For multiple instances in one parent, give each one a keyed parent scope so the component-internal keys stay distinct; the example does this for its four download bars and the loading bar.

progress is a convenience wrapper over the public parts. A linear bar keeps the default parts:

part, visible := progress.begin(ctx, &app.upload, app.value, 0, 100,
progress.Options{accessible_label="Upload progress", width=320},
key=alicorn.key_string("upload"), instance_id=43)
if visible {
progress.label(ctx, &part)
progress.value_text(ctx, &part)
track, track_visible := progress.track_begin(ctx, &part)
if track_visible {
progress.indicator(ctx, &track) // omit for a custom fill
progress.track_end(ctx)
}
progress.end(ctx, &part)
}

A ring donut uses the same begin and semantics but owns its surfaces. The component supplies the fraction-to-arc math:

part, visible := progress.begin(ctx, &app.export, app.value, 0, 100,
progress.Options{accessible_label="Export", width=180},
key=alicorn.key_string("export-ring"), instance_id=44)
if visible {
// ... a circle track surface, then:
arc := progress.ring_shape(part.normalized) // Arc Surface_Shape
// optional centered text:
ui.text(ctx, progress.format_value(part.normalized), key=ui.key_u64(1), size=30)
progress.end(ctx, &part)
}

Public geometry helpers: fraction, format_value, linear_geometry, ring_sweep, ring_shape, and ring_segment_shape. Track exposes inner_width, inner_height, fill_width, and offset_width for custom indicators. Semantics are published by begin; omitting visual parts never removes the accessible value or numeric range.

Three independently compilable examples cover the paths: the default bar (examples/progress), linear plus ring parts from one range (examples/progress_parts), and a dialog-hosted export (examples/progress_composition).

PartVisual partWhat can be omitted or replaced
Root—Always present; carries Progress semantics and the stable semantic ID.
Label.LabelSet hide_label to omit it; the accessible name remains.
Value.ContentSet hide_value to omit the visible value; semantic value remains.
Track.SurfaceAlways present; role and geometry are recipe/options driven.
Fill.IndicatorOmitted at 0% and for an empty unresolved range.

progress_semantic_id(instance_id) is stable across value, phase, and theme changes. A zero instance ID is rejected. Track and fill are decorative visual parts and do not add duplicate semantic entities.

Recipe declares two optional namespaced surface roles:

FieldCore fallback
track_surface_roleSubtle_Surface
fill_surface_roleAccent

Zero roles need no theme registration. Configured roles are validated with theme_contract_default, theme_contract_check, theme_contract_satisfied, and theme_contract_missing_required. The example registers vendor.alikit.progress.*, activates the theme with alicorn.style_environment_push, and falls back to core roles when the recipe is zero.

Geometry lives in Options: width, track_height, track_padding, corner_radius, label/value sizes, and indeterminate_width. The track width is definite so fill geometry is exact and a value change touches only the bar’s layout frontier. value_label overrides the formatted percentage in both visible and semantic values.

Indeterminate work has no numeric value. The application supplies indeterminate_phase in 0..1; the active segment moves by that phase. pulse=true adds a paint-only opacity response through ui.motion. The application must advance the phase; the component never owns a timer. When the host reports Reduce Motion, the component declares Motion_Intent.Snap and the pulse does not animate. Selection/appearance does not rely on color alone: value text and segment position carry the state.

  • Progress is non-interactive: no Tab stop, key map, or actions.
  • The semantic node publishes role Progress, the accessible label, and a human-readable value ("42%", or "Loading" when indeterminate).
  • Determinate progress publishes semantic_numeric_range(clamped_value, minimum, maximum, 0). The numeric and visible values use the same clamped fraction; a non-positive range reports 0 without dividing by zero.
  • Indeterminate progress does not publish numeric range properties, so assistive technology does not announce a fabricated percentage.
  • Not claimed: task cancellation, estimated remaining time, or live-region announcements on every value change. A progress bar is not a status log.

progress/progress_test.odin covers:

  • fraction clamping and the zero-range case;
  • role, label, value text, numeric range, and stable identity;
  • a value change driven by ordinary input with updated semantics and a bounded layout frontier (layout_nodes_visited < 80);
  • indeterminate mode having no numeric value and reporting "Loading";
  • caller-driven phase moving the segment without changing its width;
  • reduced-motion observation reflected in state, with a snapped pulse settling through an advance-time turn;
  • the theme contract reporting configured and missing roles.
Terminal window
odin test progress -define:ODIN_TEST_THREADS=1 -collection:alicorn=<alicorn> -collection:alikit=.
./out/progress_example.exe --smoke

There is no testui pattern kind for a progress bar. It is a non-interactive presentation contract; explicit semantic assertions are the appropriate conformance check.

DeclarationNotes
OptionsLabels, width, track geometry, label/value sizes, indeterminate phase/width, pulse, hide_label, hide_value, value_label.
RecipeOptional track/fill namespaced surface roles.
StateDiagnostic resolved fraction, phase, reduced-motion decision, and segment geometry.
Progress / TrackPer-description root and track contexts with public value/geometry fields.
beginOpens the root and publishes Progress semantics; returns (Progress, visible).
label / value_textOptional default visual parts.
track_begin / indicator / track_endOptional default linear track and fill.
endCloses the progress root.
progressConvenience wrapper built from the parts.
progress_semantic_idStable semantic identity from the instance ID.
fraction, format_valuePure clamped fraction and percentage text helpers.
linear_geometry, ring_sweep, ring_shape, ring_segment_shapePublic linear and ring geometry math.
recipe_defaultCore-role recipe.
theme_contract_default, theme_contract_check, theme_contract_satisfied, theme_contract_missing_requiredSetup-time validation.
  • The track has a definite width. A fill percentage needs a definite parent; the component deliberately avoids a second percentage-width policy.
  • Continuous indeterminate motion is application-owned. The component provides phase mapping and an optional motion declaration, not a scheduler.
  • The value text uses %.0f%%; supply value_label for units or localization.
  • Headless tests do not prove pixels, native high-contrast rendering, or an assistive-technology announcement.
Pin: built and captured against Alicorn 47c9d4a7cd1f637876190fec899daeeac00a30ae. See Compatibility and pinning.