Progress 进度条
展示操作当前进度,支持线形、圆形、仪表盘与分段进度
展示操作的当前进度,支持状态色、渐变、分段进度与自定义文案。
何时使用
- 操作耗时较长,需要让用户明确感知进度时;
- 展示任务完成度、上传 / 下载进度等数值时;
- 需要以环形或仪表盘形式展示占比时。
导入
代码演示
基础用法与状态
status 支持 normal / active(流光)/ success / exception;不传时进度达到 100% 自动进入 success。
圆形与仪表盘
type="circle" 为完整圆环,type="dashboard" 为带缺口的仪表盘;size 为直径(默认 120,small 为 60)。
分段、渐变与自定义文案
steps:线形分段进度,传数字或{ count, gap };strokeColor:线形支持纯色与渐变{ from, to, direction };format:自定义数值文案,也可使用#format插槽。
API
Props
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
type | 进度条类型 | "line" | "circle" | "dashboard" | "line" |
percent | 当前进度百分比(0-100,超出自动钳制) | number | 0 |
showInfo | 是否显示数值 / 状态图标 | boolean | true |
status | 状态;不传时 100% 自动为 success | "normal" | "active" | "success" | "exception" | — |
strokeColor | 进度颜色,线形支持渐变对象 | string | { from: string; to: string; direction?: string } | — |
trailColor | 轨道颜色 | string | — |
strokeWidth | 线形为像素高度;圆形 / 仪表盘为描边宽度(viewBox 百分比) | number | 线形 8 / 圆形 6 |
strokeLinecap | 线条端点样式(圆形 / 仪表盘) | "round" | "butt" | "square" | "round" |
size | 线形为高度或 [宽度, 高度];圆形 / 仪表盘为直径 | "small" | "default" | number | [number, number] | "default" |
success | 已成功进度(仅线形且非分段) | { percent?: number; strokeColor?: string } | — |
steps | 分段进度(仅线形) | number | { count?: number; gap?: number } | — |
format | 自定义进度文案(返回字符串) | (percent: number) => string | — |
gapDegree | 仪表盘缺口角度 | number | 75 |
gapPosition | 仪表盘缺口位置 | "top" | "right" | "bottom" | "left" | "bottom" |
class | 附加类名 | string | — |
Slots
| 名称 | 说明 | 参数 |
|---|---|---|
format | 自定义进度文案(优先于 format 属性) | { percent: number } |
说明
- 默认使用主题
--primary;成功为绿色、异常为红色,可通过strokeColor/trailColor覆盖; - 圆形与仪表盘的
strokeColor传入渐变对象时使用from颜色(与 antd 行为一致); - 开启
steps时忽略success。
