Skip to main content

rc-progress

Native <progress> enhancer with a formatted value display, a restylable track/fill, and a built-in fix for the indeterminate/undefined-binding footgun.

Package
@rcarls/rc-progress
Element
<rc-progress>
Native dependency
Requires a native progress child
State model
Controlled or uncontrolled numeric value
Main events
rc-progress-complete

Installation

npm install @rcarls/rc-progress
import '@rcarls/rc-progress/define';

Live demo

Determinate vs. indeterminate

Binding undefined to a live <progress>.value throws. Toggle the indeterminate attribute instead: the component removes and restores the native element's value attribute for you, so you never have to reach for that binding yourself.

Doing one job

rc-progress does not render a dialog, own any phase state, or assume anything about where it's placed. It composes cleanly with rc-dialog, a card, or an inline status row: bring your own chrome, and let rc-progress handle the bar.

Theming

The default demo mode shows the component without a package theme. Use the shared preview controls on this page to compare inherited, light, and dark color schemes or to apply the optional Material theme only inside the demo frames.

API

Properties

PropertyMarkupTypeDefaultDescription
valuevaluenumberNot specifiedCurrent progress value.
defaultValuedefault-valuenumber | undefinedNot specifiedInitial uncontrolled value. Has no effect after the first host write.
maxJS property onlynumberNot specifiedMaximum progress value, read directly from the native `<progress>` child's own `max` IDL property (native default `1`) rather than duplicated as a separate host attribute — the consumer already owns it by setting `max` on the slotted `<progress>` element.
indeterminateindeterminatebooleanfalseWhen present, the component removes the native `<progress>`'s `value` attribute instead of asking the consumer to bind `undefined` to it — binding `undefined` to a live `<progress>.value` throws.
disableddisabledbooleanfalseVisual-only dimming; native `<progress>` has no functional disabled state.
displaydisplayDisplayValuenullControls the live value display. - Absent (default) — no value shown. - `overlay` (or bare `display`) — centered on the bar. - `display="inline-start"` — rendered before the track, inline in the grid. - `display="inline-end"` — rendered after the track, inline in the grid.
valueTextvalue-textstring''Screen-reader value text. When set, forwarded as `aria-valuetext` on the native `<progress>` and used as the default formatted display text.
orientationorientation'horizontal' | 'vertical''horizontal'Orientation; reflected as an attribute and forwarded to `aria-orientation`.

Methods

No public methods are documented in the custom elements manifest.

Events

EventDetail typeDescription
rc-progress-completeCustomEventFires once when `value` reaches `max` while not indeterminate. Does not re-fire on subsequent updates while already at max.

Slots

NameDescription
(default)Place a `<progress>` element here.
value-displayOptional replacement for the rendered value text.

CSS Custom Properties

PropertyDefaultDescription
--rc-progress-control-size0.5remTrack hit-area block size.
--rc-progress-vertical-size12.5remTrack length when `orientation="vertical"`.
--rc-progress-gapvar(--rc-control-gap)Gap between track and inline value display.
--rc-progress-track-backgroundCanvasTextUnfilled track color.
--rc-progress-track-opacity0.25Unfilled track opacity.
--rc-progress-track-radiusvar(--rc-control-radius)Track border radius.
--rc-progress-fill-backgroundvar(--rc-accent)Filled track color.
--rc-progress-value-colorvar(--rc-text-disabled)Value display text color.

CSS Parts

PartDescription
rootRoot layout wrapper.
controlTrack positioning wrapper.
trackVisual track.
fillFilled progress segment.
value-displayRendered value text.