Skip to content

Progress Ring

A circular progress indicator with its percent in the middle. It is an SVG ring with role="progressbar", and the arc length is set through stroke-dasharray on a path of length 100.

Decision

When Use
A known percent where space is tight, such as a queue row Progress Ring
A thin line in a row Progress Bar

Usage

import { createProgressRing } from './configurationpage?name=myplugin_stolon.js';

var ring = createProgressRing({ value: 40, color: 'green' });
ring.setValue(65);

Classes: stolon-ring, stolon-ring-small, stolon-ring-medium, stolon-ring-large, stolon-ring-pie, stolon-ring-arc. The handle is { element, getValue, setValue, destroy }.

Parts: stolon-ring-track, stolon-ring-value.

States and Modifiers

  • value is a percent from 0 to 100. setValue clamps it and updates aria-valuenow.
  • size is small, medium (default), or large. color is a status color name or a hex code for the arc, the accent by default. A hex code sets --stolon-custom on the ring.
  • showValue: false hides the percent text. label ("Progress") is the aria-label.
  • pie: true fills a small disc like a pie, with no text, such as beside a small button. The Task Progress Button draws one.

Reference

Generated from the code by scripts/build-docs.mjs. Edit the code, not this section.

createProgressRing

function createProgressRing(options?: ProgressRingOptions): ProgressRingHandle

A circular progress indicator with its percent in the middle. It is an SVG ring, role progressbar, and the arc length is set through stroke-dasharray on a path of length 100.

Option Type What it does
value number | string percent from 0 to 100 (default 0)
size 'small' | 'medium' | 'large' | string 'small', 'medium', or 'large' (default 'medium')
color string status color name or hex code for the arc, such as 'green' or '#e91e63' (default the accent)
label string aria-label (default 'Progress')
showValue boolean false hides the percent text (default true)
pie boolean true fills a small disc like a pie, with no text, such as beside a small button (default false)
Handle member Type
getValue (): number
setValue (next: number | string): void
destroy (): void
Class What it looks like
stolon-ring Circular progress with its percent in the middle, in three sizes and any status color
stolon-ring-pie A small disc that fills like a pie with no text, such as beside a small button that is running a task

Example

Example Code

<!-- title: Progress Ring -->
<div id="mount"></div>
<script type="module">
const base = await window.__baseReady;
const view = document.getElementById('view');
const mount = document.getElementById('mount');
mount.style.cssText = 'display:flex;align-items:center;gap:16px';
[['small', 25, ''], ['medium', 60, 'green'], ['large', 90, 'orange']].forEach(([size, value, color]) => mount.appendChild(base.createProgressRing({ size, value, color }).element));
</script>