Skip to content
API 风格:

CircleProgress 環形進度 ​

環形進度:viewBox 跟隨 size 等比縮放(不再是 progress 元件 circle 形態的固定 100×100 畫布),半徑、周長、stroke-dasharray 全部由 @lh-ui/share/core/circle-progress 純邏輯換算(getCircleRadius / getCircleCircumference / getCircleDashArray), 視覺零分叉。支援漸層色(color 陣列)、自訂起始角(startAngle)、 逆時針(clockwise)、描邊端點(linecap)與文案格式化(format)。

基礎用法 ​

受控百分比
70%
100%
vue
<script setup lang="ts">
import { ref } from 'vue'
import { LhCircleProgress } from '@lh-ui/vue3'

// 純受控元件:自身不發射事件,百分比由外部狀態驅動
const percentage = ref(70)
</script>

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

漸層色 ​

color 傳陣列(≥2 項)時,元件算繪 defs 內唯一的 linearGradient (id 基於實例 uid,多實例不撞名),首尾對齊陣列端點:

漸層進度環
60%
85%
vue
<LhCircleProgress :model-value="60" :color="['#2B4C7C', '#D9393B']" />

逆時針與起始角 ​

clockwise=false 時 svg 追加 scaleX(-1) 鏡像;startAngle 以 12 點鐘方向為 0 度、順時針為正(0 = 頂部、90 = 3 點鐘、180 = 底部、270 = 9 點鐘):

方向與起點
75%
75%
75%

自訂文案與軌道色 ​

format 格式化預設文案;預設插槽覆寫整段文案;trackColor 透傳軌道描邊色 (未傳走 --lh-bg-color-disabled 令牌):

文案與軌道
已完成 66%
進度 42 分
55%

API ​

CircleProgress Props ​

屬性說明類型預設值
modelValue進度百分比 0-100(受控,預設 0,超出自動鉗制)number0
size環尺寸 px(直徑)number120
strokeWidth描邊寬度 pxnumber6
color進度色:單色字串或漸層色陣列(陣列 ≥2 項首尾作漸層端點)string | string[]—
trackColor軌道色(未傳走 lh-circle-progress-track 令牌)string—
clockwise順時針(預設 true)booleantrue
startAngle起始角度(度,0 = 12 點鐘方向,順時針為正)number0
showText顯示預設百分比文案booleantrue
format文案格式化(預設取整百分號)LhCircleProgressFormatter—
linecap描邊端點形狀(預設 round)LhCircleProgressLinecap'round'
label無障礙可達名稱string—
sxsx 快速版面配置屬性LhSxProps—

CircleProgress Slots ​

插槽名說明作用域參數
default覆寫預設百分比文案{ percentage: number }

無障礙 ​

根節點為 role="progressbar",帶 aria-valuemin=0 / aria-valuemax=100 / aria-valuenow=鉗制後的百分比;label 作為可達名稱(無可見文案時建議必傳)。 文案容器 pointer-events: none,不干擾互動。