Liking cljdoc? Tell your friends :D

x-progress

A linear progress bar web component with variant colors, optional value label, indeterminate animation, and a completion event.

Tag

<x-progress value="60" max="100"></x-progress>

Observed Attributes

AttributeTypeDefaultValues
valuenumber0Numeric string, clamped to [0, max]
maxnumber100Numeric string > 0; falls back to 100
variantenumdefaultdefault success warning danger
sizeenummdsm md lg
labelstringVisible label rendered above the track
show-valuebooleanabsentShows computed percentage text
indeterminatebooleanabsentAnimated shimmer; ignores value

Properties

PropertyTypeReflects attribute
valuestringvalue
maxstringmax
indeterminatebooleanindeterminate
showValuebooleanshow-value

Events

EventBubblesDetailWhen
x-progress-completeyes{ value: number, max: number }Once when value >= max; resets when value < max

Slots

None. Label text is provided via the label attribute.

CSS Custom Properties

PropertyDefaultDescription
--x-progress-height4px / 8px / 12px (by size)Track height
--x-progress-track-colorAdaptive muted greyBackground of the track
--x-progress-fill-colorVariant-driven (blue / green / amber / red)Fill color
--x-progress-border-radius9999pxRadius for track and fill
--x-progress-label-colorAdaptive mutedColor of the label text
--x-progress-value-colorAdaptive mutedColor of the percentage value text

Accessibility

  • role="progressbar" is set on the host element.
  • aria-valuenow, aria-valuemin="0", aria-valuemax reflect the current numeric state.
  • aria-valuetext shows e.g. "75%" or "Loading…" when indeterminate.
  • aria-label mirrors the label attribute.
  • aria-busy="true" is set when indeterminate is present; removed otherwise.

Shadow DOM Structure

:host [role=progressbar aria-valuenow aria-valuemin aria-valuemax aria-valuetext]
  <style>
  <div part="base" data-variant data-size data-indeterminate>
    <div part="header">           ← hidden when neither label nor show-value
      <span part="label-text">   ← textContent = label attribute
      <span part="value-text">   ← textContent = "75%" when show-value
    <div part="track">
      <div part="fill">          ← width driven by inline style %

Usage Examples

Basic

<x-progress value="40"></x-progress>

With label and value display

<x-progress value="75" label="Upload progress" show-value></x-progress>

Variants

<x-progress value="100" variant="success"></x-progress>
<x-progress value="60"  variant="warning"></x-progress>
<x-progress value="30"  variant="danger"></x-progress>

Sizes

<x-progress value="50" size="sm"></x-progress>
<x-progress value="50" size="md"></x-progress>
<x-progress value="50" size="lg"></x-progress>

Indeterminate

<x-progress indeterminate label="Loading…"></x-progress>

Listening for completion

document.querySelector('x-progress').addEventListener('x-progress-complete', e => {
  console.log('Done!', e.detail); // { value: 100, max: 100 }
});

Custom theme

x-progress {
  --x-progress-fill-color: #8b5cf6;
  --x-progress-track-color: #ede9fe;
  --x-progress-height: 10px;
}

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close