跳到主要内容

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'