CircleProgress
Circular progress indicator: renders an inline SVG (viewBox 0 0 size size) with a
track circle (lh-circle-progress__track) and an arc circle
(lh-circle-progress__arc) whose stroke-dasharray drives the filled ratio. All
geometry, clamping, color normalization and text formatting are consumed from
@lh-ui/share/core/circle-progress pure functions, so the semantics are identical
across all platforms.
modelValueis clamped to[0, 100](no error for out-of-range values).startAngleuses the clock convention:0= 12 o'clock, clockwise positive. The SVG default starting point (3 o'clock) is compensated by an inlinerotate(startAngle - 90deg)transform on the svg element.clockwisedefaults totrue;falseappendsscaleX(-1)to the same inline transform so the arc sweeps counterclockwise from the same origin.coloraccepts a single color or an array; arrays with 2+ entries render adefs > linearGradient(id generated viaReact.useId(), unique per instance) and the arc references it viastroke="url(#id)".
Basic usage
CircleProgress (default / gradient / counterclockwise / start angle / custom format / no text)
70%100%60%50%88 分
import { LhCircleProgress } from '@lh-ui/react'
export default function Demo() {
return (
<>
<LhCircleProgress modelValue={70} />
<LhCircleProgress modelValue={100} color="#E4007E" />
<LhCircleProgress modelValue={60} color={['#2B4C7C', '#E4007E']} size={80} />
<LhCircleProgress modelValue={50} clockwise={false} startAngle={90} />
<LhCircleProgress modelValue={88} format={(v) => `${v} 分`} />
<LhCircleProgress modelValue={40} showText={false} />
</>
)
}
Custom text
By default the center shows the rounded percentage (via formatCircleText).
format replaces the text content, and children overrides the default text
entirely (aligning with the default slot semantics of other platforms):
<LhCircleProgress modelValue={42} format={(v) => `${v} / 100 分`} />
<LhCircleProgress modelValue={50}>
<em className="my-text">自定义</em>
</LhCircleProgress>
CircleProgress API
| Prop | Description | Type | Default |
|---|---|---|---|
| modelValue | Progress percentage 0-100 (clamped; default 0) | number | 0 |
| size | Ring diameter in px | number | 120 |
| strokeWidth | Stroke width in px | number | 6 |
| color | Progress color: single color, or an array (2+ entries render a gradient) | string | string[] | theme token |
| trackColor | Track color (falls back to the track token) | string | theme token |
| clockwise | Clockwise sweep (false appends scaleX(-1) to the svg transform) | boolean | true |
| startAngle | Start angle in degrees (0 = 12 o'clock, clockwise positive) | number | 0 |
| showText | Show the default percentage text | boolean | true |
| format | Text formatter (receives the clamped percentage) | (percentage: number) => string | rounded % |
| linecap | Stroke endpoint shape | 'butt' | 'round' | 'square' | 'round' |
| label | Accessible name (aria-label) | string | — |
| children | Overrides the default text (default slot semantics) | ReactNode | — |
| sx | Quick layout props | LhSxProps | — |
Accessibility
- The root carries
role="progressbar"witharia-valuemin/aria-valuemax/aria-valuenow(the clamped percentage), plusaria-valuetext(the rendered text) so screen readers announce a meaningful value. - Provide
labelwhen the surrounding context does not describe the task.