Skip to content

CircleProgress ​

Ring progress component: the track circle and progress arc are drawn with the canvas 2d API (drawCircleTrack / drawCircleArc, unified in share core, identical on web and mini-programs), while the text is an absolutely positioned view layered over the canvas. Serves task progress, loading ratios, score ratios and similar scenarios.

Platform differences (registered): this port uses the canvas 2d form — mini-program templates cannot render SVG (the share circle-progress SVG styles target the web port), so this port consumes the same share-core drawing pure functions via <canvas type="2d">; geometry (radius / sweep angle / counterclockwise conversion), color normalization and text formatting all reuse share core; the port only fetches the canvas context and schedules redraws. The component is event-free and fully controlled.

Basic usage ​

vue
<template>
  <lh-circle-progress :model-value="40" />
  <lh-circle-progress :model-value="70" :size="140" :stroke-width="12" />
</template>

Custom colors and gradients ​

color accepts a single color string or an array of colors; an array with 2 or more entries becomes a linear gradient whose endpoints follow the array order. When trackColor is omitted, the track token fallback color is used:

vue
<lh-circle-progress :model-value="70" color="#B87800" track-color="#F0EBE2" />
<lh-circle-progress :model-value="80" :color="['#2B4C7C', '#C4A35A']" />
<lh-circle-progress :model-value="80" :color="['#5B8C5A', '#C4A35A', '#B23A3A']" />

Counterclockwise and start angle ​

clockwise defaults to true (clockwise); startAngle counts from the 12 o'clock position as 0 degrees, positive clockwise:

vue
<lh-circle-progress :model-value="55" :clockwise="false" />
<lh-circle-progress :model-value="55" :start-angle="90" />
<lh-circle-progress :model-value="55" :start-angle="135" :clockwise="false" />

Custom text ​

The default text is the rounded percentage; format overrides formatting, the default slot replaces the whole text, and showText=false hides the text (the root gets the lh-circle-progress--no-text modifier):

vue
<lh-circle-progress :model-value="42" :format="(v: number) => `${v} pts`" />
<lh-circle-progress :model-value="100">Done</lh-circle-progress>
<lh-circle-progress :model-value="30" :show-text="false" />

Props ​

PropDescriptionTypeDefault
modelValueProgress percentage 0-100 (controlled, clamped when out of range)number0
sizeRing size in px (diameter, canvas width and height)number120
strokeWidthStroke width in pxnumber6
colorProgress color: single color or gradient array (>=2 entries become linear gradient endpoints)`stringstring[]`
trackColorTrack color (falls back to the token fallback color)stringdisabled color fallback
clockwiseClockwise (false draws counterclockwise)booleantrue
startAngleStart angle in degrees (0 = 12 o'clock, positive clockwise)number0
showTextShow the default percentage textbooleantrue
formatText formatter (rounded percentage by default)(v: number) => string—
linecapStroke linecap shape`'butt''round'
labelAccessibility labelstring—
customClassCustom class (forwarded to the root node)string—
sxsx quick layout propsLhSxProps—

Accessibility ​

The root node carries role="progressbar" with the aria-valuemin/max/now range semantics; label provides the accessible name (e.g. "Upload progress"), and modelValue is clamped into 0-100 before being announced.