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 | 圓形模式畫布寬度 px | number | — | 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'