Progress 进度条

展示操作当前进度,支持线形、圆形、仪表盘与分段进度

展示操作的当前进度,支持状态色、渐变、分段进度与自定义文案。

何时使用

  • 操作耗时较长,需要让用户明确感知进度时;
  • 展示任务完成度、上传 / 下载进度等数值时;
  • 需要以环形或仪表盘形式展示占比时。

导入

import { Progress } from "@reglow/reui";
import type { ProgressProps } from "@reglow/reui";

代码演示

基础用法与状态

status 支持 normal / active(流光)/ success / exception;不传时进度达到 100% 自动进入 success。

<script setup lang="ts">
import { Progress } from "@reglow/reui";
</script>

<template>
  <div class="w-full max-w-md space-y-4">
    <Progress :percent="30" />
    <Progress :percent="60" status="active" />
    <Progress :percent="100" />
    <Progress :percent="60" status="exception" />
  </div>
</template>

圆形与仪表盘

type="circle" 为完整圆环,type="dashboard" 为带缺口的仪表盘;size 为直径(默认 120,small 为 60)。

<script setup lang="ts">
import { Progress } from "@reglow/reui";
</script>

<template>
  <div class="flex flex-wrap items-center gap-6">
    <Progress type="circle" :percent="75" />
    <Progress type="circle" :percent="100" size="small" />
    <Progress type="dashboard" :percent="65" />
  </div>
</template>

分段、渐变与自定义文案

  • steps:线形分段进度,传数字或 { count, gap };
  • strokeColor:线形支持纯色与渐变 { from, to, direction };
  • format:自定义数值文案,也可使用 #format 插槽。
<script setup lang="ts">
import { Progress } from "@reglow/reui";
</script>

<template>
  <div class="w-full max-w-md space-y-5">
    <Progress :percent="60" :steps="5" />
    <Progress
      :percent="70"
      :stroke-color="{ from: '#108ee9', to: '#87d068' }"
    />
    <Progress :percent="45" :format="(percent) => `已用 ${percent}%`" />
  </div>
</template>

API

Props

参数说明类型默认值
type进度条类型"line" | "circle" | "dashboard""line"
percent当前进度百分比(0-100,超出自动钳制)number0
showInfo是否显示数值 / 状态图标booleantrue
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仪表盘缺口角度number75
gapPosition仪表盘缺口位置"top" | "right" | "bottom" | "left""bottom"
class附加类名string—

Slots

名称说明参数
format自定义进度文案(优先于 format 属性){ percent: number }

说明

  • 默认使用主题 --primary;成功为绿色、异常为红色,可通过 strokeColor / trailColor 覆盖;
  • 圆形与仪表盘的 strokeColor 传入渐变对象时使用 from 颜色(与 antd 行为一致);
  • 开启 steps 时忽略 success。