Skip to content
API 风格:

CircleProgress ​

Circular progress: the viewBox scales proportionally with size (no longer the fixed 100×100 canvas of the progress component's circle form). Radius, circumference and stroke-dasharray are all computed by pure logic in @lh-ui/share/core/circle-progress (getCircleRadius / getCircleCircumference / getCircleDashArray), with zero visual divergence. Supports gradient colors (color array), custom start angle (startAngle), counter-clockwise (clockwise), stroke linecap (linecap) and text formatting (format).

Basic Usage ​

Controlled percentage
70%
100%
vue
<script setup lang="ts">
import { ref } from 'vue'
import { LhCircleProgress } from '@lh-ui/vue3'

// Fully controlled component: emits no events itself; the percentage is driven by external state
const percentage = ref(70)
</script>

<template>
  <LhCircleProgress :model-value="percentage" />
</template>

Gradient colors ​

When color is an array (≥2 items), the component renders a single linearGradient inside defs (the id is based on the instance uid, so multiple instances never collide), with both ends aligned to the array endpoints:

Gradient progress ring
60%
85%
vue
<LhCircleProgress :model-value="60" :color="['#2B4C7C', '#D9393B']" />

Counter-clockwise and start angle ​

When clockwise=false the svg adds a scaleX(-1) mirror; startAngle treats the 12 o'clock direction as 0 degrees, with clockwise being positive (0 = top, 90 = 3 o'clock, 180 = bottom, 270 = 9 o'clock):

Direction and start point
75%
75%
75%

Custom text and track color ​

format formats the default text; the default slot overrides the whole text; trackColor passes through the track stroke color (falls back to the --lh-bg-color-disabled token when not passed):

Text and track
Completed 66%
Progress 42
55%

API ​

CircleProgress Props ​

PropDescriptionTypeDefault
modelValueProgress percentage 0-100 (controlled, defaults to 0, auto-clamped when out of range)number0
sizeRing size in px (diameter)number120
strokeWidthStroke width in pxnumber6
colorProgress color: a single-color string or a gradient color array (an array of ≥2 items uses both ends as gradient endpoints)string | string[]—
trackColorTrack color (falls back to the lh-circle-progress-track token when not passed)string—
clockwiseClockwise (true by default)booleantrue
startAngleStart angle (degrees, 0 = 12 o'clock direction, clockwise being positive)number0
showTextShow the default percentage textbooleantrue
formatText formatter (defaults to a rounded percentage sign)LhCircleProgressFormatter—
linecapStroke linecap shape (round by default)LhCircleProgressLinecap'round'
labelAccessible namestring—
sxsx quick-layout propsLhSxProps—

CircleProgress Slots ​

SlotDescriptionScoped props
defaultOverrides the default percentage text{ percentage: number }

Accessibility ​

The root node is role="progressbar" with aria-valuemin=0 / aria-valuemax=100 / aria-valuenow=<clamped percentage>; label serves as the accessible name (recommended, and effectively required, when there is no visible text). The text container has pointer-events: none so it does not interfere with interaction.

Beauty of tradition, foundation of code