跳到主要內容

Progress 進度條

展示任務或容量的完成進度,支援線形與圓形兩種形態,可自訂顏色與文字。

基礎用法​

基礎用法
60%
100%
80%
40%
55%
70 分
75%
100%
30%
import { LhProgress } from '@lh-ui/react'

export default function Demo() {
return (
<>
<LhProgress percentage={60} />
<LhProgress percentage={80} status="warning" />
<LhProgress type="circle" percentage={75} />
</>
)
}

Progress Props​

屬性說明型別可選值預設值
percentage進度百分比,超出 [0, 100] 自動鉗制number—0
type形態'line' | 'circle'—'line'
status狀態,normal 時達到 100 自動轉為 success'normal' | 'success' | 'warning' | 'exception'—'normal'
color進度條顏色:字串或依百分比回傳顏色的函式string | ((percentage: number) => string)——
strokeWidth線條寬度 px(line 為高度,circle 為描邊寬度)number—6
width圓形模式畫布寬度 pxnumber—126
showText是否展示文字boolean—true
format自訂文字內容(接收鉗制後的百分比,回傳 ReactNode)(percentage: number) => ReactNode——
sx快速佈局屬性SxProps——
與 Vue 版的對應

percentage / type / status / color / strokeWidth / width / showText 與 lh-ui-plus 的 LhProgress 同名同義;React 無插槽,plus 的 format prop 與 #text 作用域插槽合併為一個 format 渲染函式(接收鉗制後的百分比,回傳 ReactNode)。

無障礙

根元素帶 role="progressbar" 與 aria-valuemin / aria-valuemax / aria-valuenow,對齊 WAI-ARIA progressbar 模式;aria-valuetext 同步可見文案——預設為百分比,傳 format 時播報格式化後的文字 (format 回傳非字串時回退為百分比取整文案)。

樣式​

import '@lh-ui/react/style/progress'