Skip to content
// EFFECT DAYS 2026

Progress unstable

A progress bar for a task that takes a while, whose value lives in the consumer's Model. It is a headless component: the label needs an id for the bar to point at. It keeps no state of its own, and emits nothing.

Anatomy

Part Element
root <div role="progressbar">
label <span> inside the root
value <span> inside the root
track <div> inside the root
indicator <div> inside the track

Each part takes the consumer's builder and returns it, so the consumer goes on chaining and adds children with .children(...). root appends a visually hidden, non-selectable <span role="presentation"> after all its children so NVDA reads the label without leaking into copied text. value fills in the value text when the consumer gives it no children. The other parts add no markup.

The root's aria-labelledby always points at the label's id. When you draw no label, name the bar with aria-label on the root: a screen reader skips an id that nothing has.

Data attributes

On every part, each present with an empty value or absent:

  • data-progressing: the value is below max
  • data-complete: the value is max or above
  • data-indeterminate: the value is null

Keyboard

None: the bar isn't focusable and handles no events.

Indicator width

While the value is known, indicator adds inset-inline-start:0;height:inherit;width:<percentage>% after the consumer's inline style, so its width wins and other declarations stay. Only the CSS percentage is rounded, to at most 3 decimal places. While indeterminate, indicator adds nothing. To draw the bar vertically or as a ring, skip indicator and use the unrounded progress.percentage.

Example A labelled upload bar

import { Html, HtmlServer } from "effect/ui/html"
import { Progress } from "effect/ui/kit"
import { Effect, Schema } from "effect"
const Upload = Html.component({
name: "Upload",
model: Schema.Struct({ sent: Schema.Number }),
message: Schema.Never
}).make({
init: () => ({ sent: 40 }),
update: ($) => $.model,
view: (h, model) =>
Progress(h, {
props: { value: model.sent },
view: (progress) =>
progress.root(h.div.class("progress")).children(
progress.label(h.span).children("Uploading"),
progress.value(h.span),
progress.track(h.div.class("track")).children(progress.indicator(h.div.class("fill")))
)
})
})
// The root keeps the consumer's class, reports the value, and the indicator is 40% wide.
const { html } = await Effect.runPromise(HtmlServer.renderToHtml(Upload, {}))
if (!/<div class="progress"[^>]* role="progressbar"[^>]* aria-valuenow="40"/.test(html)) {
throw new Error("the root isn't a progress bar at 40")
}
if (!/<div class="fill"[^>]* style="[^"]*width:40%"/.test(html)) throw new Error("the indicator isn't 40% wide")
4 exports Since v4.2.0 Source

Components

Progress

unstable
Since v4.2.0

A headless progress bar. Call it with the consumer's h, the props, and a view closure that draws the root with progress.root(h.div), usually with a label, the value and a track holding the indicator inside it.

Details

The parts also return:

  • status: a ProgressStatus
  • percentage: the value's share of the range, from 0 to 100, or null while indeterminate
  • valueText: the text value shows, or undefined when it shows none

The progress bar's own attributes win over the ones the consumer set on the builder before the part, including the ones a state leaves absent:

  • root: role, aria-valuemin, aria-valuemax, aria-valuenow (absent while indeterminate) and aria-valuetext (absent while indeterminate without valueText). aria-labelledby is a token list: the label's id is added to the consumer's own.
  • label: id and role="presentation"
  • value: aria-hidden="true", as the root already reports the value
  • every part: the data attributes

A part writes them when it is applied, so an attribute the consumer chains after the part is the consumer's to answer for. The indicator's width and the root's hidden span are added when the element is built, after everything the consumer chained.

Signature

declare const Progress: Headless<{
readonly max?: number;
readonly min?: number;
readonly value: number | null;
readonly valueText?: string;
}, never, {
indicator: Part<"div", [], never>;
label: Part<"span", [], never>;
percentage: number | null;
root: Part<"div", [], never>;
status: ProgressStatus;
track: Part<"div", [], never>;
value: Part<"span", [], never>;
valueText: string | undefined;
}, never, never, never, never, never, never, {}, never, QueryEntries<{}, {}>>

Models

ProgressProps

type unstable
Since v4.2.0

The props of a Progress.

Signature

type ProgressProps = typeof ProgressProps.Type

ProgressStatus

type unstable
Since v4.2.0

Where the task is: "progressing" below max, "complete" at max, and "indeterminate" while the value is unknown.

Signature

type ProgressStatus = "indeterminate" | "progressing" | "complete"

Schemas

Since v4.2.0

Props for the value of a Progress.

Details

  • value: how far the task has got, between min and max. Required: the consumer owns it. null, or a number that isn't finite, means the progress is unknown (indeterminate). A value outside the range is clamped to it.
  • min and max: the range, 0 and 100 by default.
  • valueText: the text that describes the value, as the root's aria-valuetext and as what value shows, in every state. Left out, it is the percentage, rounded to a whole number, as "40%", the same on the server and in the browser. While indeterminate without valueText, aria-valuetext is omitted and value shows nothing. Build your own text, such as "3 of 5 files", in the view from your Model.

Signature

declare const ProgressProps: Struct<{
readonly max: optional<Number>;
readonly min: optional<Number>;
readonly value: NullOr<Number>;
readonly valueText: optional<String>;
}>