# CircleProgress

A circular progress indicator: two svg circles (track + progress arc) express a percentage. It is purely controlled, with no internal state and no events. All geometry math (radius / circumference / dasharray / start rotation) and color normalization live in the pure logic of @lh-ui/share/core/circle-progress; this component is only the reactive glue and the template.

modelValue is a controlled percentage of 0-100; out-of-range values are clamped by the share core (clampPercent). startAngle treats 12 o'clock as 0 degrees with clockwise positive (matching the clock hands); when clockwise=false the svg gets an extra scaleX(-1) to flip the sweep direction.

CircleProgress (size / solid and gradient / direction and start angle / text)
<template>
  <div class="demo-col" style="gap: 18px; flex-wrap: wrap; flex-direction: row; align-items: flex-start">
    <div class="demo-col" style="align-items: center; gap: 8px">
      <LhCircleProgress :model-value="percent" />
      <span class="demo-note">Default (controlled percent={{ percent }})</span>
    </div>
    <div class="demo-col" style="align-items: center; gap: 8px">
      <LhCircleProgress :model-value="percent" :size="80" :stroke-width="4" />
      <span class="demo-note">size=80 strokeWidth=4</span>
    </div>
    <div class="demo-col" style="align-items: center; gap: 8px">
      <LhCircleProgress :model-value="percent" color="#A63D40" track-color="#EDE8E0" />
      <span class="demo-note">Solid color + trackColor</span>
    </div>
    <div class="demo-col" style="align-items: center; gap: 8px">
      <LhCircleProgress :model-value="percent" :color="['#2B4C7C', '#3A7D5A']" />
      <span class="demo-note">Two-color gradient</span>
    </div>
    <div class="demo-col" style="align-items: center; gap: 8px">
      <LhCircleProgress :model-value="percent" :clockwise="false" :start-angle="90" />
      <span class="demo-note">Counterclockwise + start at 3 o'clock</span>
    </div>
    <div class="demo-col" style="align-items: center; gap: 8px">
      <LhCircleProgress :model-value="percent" :show-text="false" linecap="butt" />
      <span class="demo-note">No text + linecap=butt</span>
    </div>
    <div class="demo-col" style="align-items: center; gap: 8px">
      <LhCircleProgress :model-value="percent" :format="format" label="Digital progress" />
      <span class="demo-note">Custom text via format</span>
    </div>
    <div class="demo-col" style="align-items: center; gap: 8px">
      <LhCircleProgress :model-value="percent" label="Collection progress">
        <span style="font-size: 12px">{{ percent }}/100</span>
      </LhCircleProgress>
      <span class="demo-note">Default slot overrides the text</span>
    </div>
    <div class="demo-row" style="gap: 12px; align-items: center">
      <LhButton size="small" @click="dec">-10</LhButton>
      <LhButton size="small" @click="inc">+10</LhButton>
    </div>
  </div>
</template>

<script>
export default {
  data: () => ({
    percent: 65,
  }),
  methods: {
    format(v) {
      return `${v}%`
    },
    inc() {
      this.percent = Math.min(this.percent + 10, 130)
    },
    dec() {
      this.percent = Math.max(this.percent - 10, -20)
    },
  },
}
</script>

# Size and stroke

size is the ring diameter (px) and strokeWidth is the stroke width (px); the radius is (size - strokeWidth) / 2, so the stroke never overflows the viewport:

<LhCircleProgress :model-value="70" :size="80" :stroke-width="4" />

# Colors

color accepts a single-color string or a gradient color array (an array with ≥2 items renders defs > linearGradient, spreading the endpoints at evenly divided offsets); trackColor overrides the track color. When neither is passed, lh-circle-progress falls back to its token defaults (--lh-primary-color / the track gray):

<LhCircleProgress :model-value="70" color="#A63D40" track-color="#EDE8E0" />
<LhCircleProgress :model-value="70" :color="['#2B4C7C', '#3A7D5A']" />

# Direction and start angle

startAngle (degrees, 0 = 12 o'clock, clockwise positive) decides where the arc starts; it is converted internally into an svg rotate transform (an svg circle starts at 3 o'clock by default); clockwise=false adds scaleX(-1) to flip the whole thing:

<LhCircleProgress :model-value="70" :clockwise="false" :start-angle="90" />

# Linecap and text

linecap takes butt / round / square (default round). With showText=false the root gets the --no-text modifier and the in-ring text is hidden; format customizes the default text (receives the clamped percentage); the default slot overrides the whole text:

<LhCircleProgress :model-value="70" :format="(v) => `${v}%`" />
<LhCircleProgress :model-value="70" label="Collection progress">
  <span style="font-size: 12px;">70/100</span>
</LhCircleProgress>

# Props

Prop Description Type Default
modelValue Progress percentage 0-100 (controlled; clamped when out of range) number 0
size Ring size in px (diameter) number 120
strokeWidth Stroke width in px number 6
color Progress color: a single-color string or a gradient color array (an array with ≥2 items becomes linearGradient endpoints) string \| string[] —
trackColor Track color (falls back to the token default when not passed) string —
clockwise Clockwise (false adds scaleX(-1) to the svg) boolean true
startAngle Start angle (degrees, 0 = 12 o'clock, clockwise positive) number 0
showText Show the default percentage text boolean true
format Text formatter (receives the clamped percentage; the default rounds to a whole percent) (percentage: number) => string —
linecap Stroke endpoint shape 'butt' \| 'round' \| 'square' 'round'
label Accessible name (aria-label) string —
sx sx shorthand layout props LhSxProps —

# Slots

Slot Description Scoped props
default Overrides the default in-ring text (renders the formatCircleText result by default) —

# Accessibility

The root element gets role="progressbar", aria-valuemin="0", aria-valuemax="100" and aria-valuenow (the clamped percentage) injected by getCircleProgressAria; label provides the accessible name (required when there is no visible text).

Last Updated: 12/4/2026, 12:49:57 AM

Copyright © 2024-2026 FengMo WenXue