Skip to content

Progress

Used to display the current progress of an operation.

Component Types

Basic Usage

Set the percentage percentage.

html
<wd-progress :percentage="50" />

Built-in Percentage

Configure the percentage to be displayed inside the progress bar through percent-position, and set the alignment.

html
<wd-progress :percentage="50" :percent-position="{ type: 'inner', align: 'center' }" />
<wd-progress :percentage="50" status="success" :percent-position="{ type: 'inner', align: 'right' }" />
<wd-progress :percentage="50" status="danger" :percent-position="{ type: 'inner', align: 'left' }" />

Component States

Status

Set status to inform the user of the current state and expectations.

html
<wd-progress :percentage="50" status="success" hide-text />
<wd-progress :percentage="50" status="danger" hide-text />
<wd-progress :percentage="50" status="warning" hide-text />

Component Styles

Hide Progress Text

Set hide-text to hide the progress text.

html
<wd-progress :percentage="50" hide-text />

Modify Color

Set color to modify the progress bar color.

html
<wd-progress :percentage="50" color="var(--wot-color-theme, #0083ff)" />
<wd-progress :percentage="50" color="var(--wot-color-success, #00c740)" />
<wd-progress :percentage="50" color="var(--wot-color-warning, #ffb300)" />

Color Array

color can also be set as a color array or ProgressColor[]. When a string array is passed in, the component will automatically calculate the progress boundary corresponding to each color segment.

html
<wd-progress :percentage="50" :color="['#00c740', '#ffb300', '#e2231a', '#0083ff']" />
<wd-progress :percentage="50" :color="colorObject" />
ts
import type { ProgressColor } from '@/uni_modules/wot-ui/components/wd-progress/types'

const colorObject: ProgressColor[] = [
  {
    color: 'yellow',
    percentage: 30
  },
  {
    color: 'red',
    percentage: 60
  },
  {
    color: 'blue',
    percentage: 80
  },
  {
    color: 'black',
    percentage: 90
  }
]

Special Styles

Dynamic Control

Dynamic progress control can be achieved by modifying the percentage binding value.

html
<wd-progress :percentage="percentage" />
<wd-button type="danger" size="small" @click="reduce">-10</wd-button>
<wd-button type="success" size="small" @click="add">+10</wd-button>
ts
const percentage = ref(50)

function add() {
  percentage.value = Math.min(percentage.value + 10, 100)
}

function reduce() {
  percentage.value = Math.max(percentage.value - 10, 0)
}

Attributes

ParameterDescriptionTypeDefault Value
percentageProgress value, maximum is 100number0
hide-textWhether to hide progress textbooleanfalse
colorProgress bar color, optional values are string, string[], ProgressColor[]string | string[] | ProgressColor[]-
statusProgress bar status, optional values are success, danger, warningstring-
durationMilliseconds required for progress to increase by 1%number30
percent-positionPercentage display position configuration, type optional inner, outer, align optional left, center, rightPercentPosition{ align: 'right', type: 'outer' }
custom-classRoot node custom class namestring''
custom-styleRoot node custom stylestring''

ProgressColor

ParameterDescriptionTypeDefault Value
colorColor valuestring-
percentageProgress threshold for color to take effectnumber-

PercentPosition

ParameterDescriptionTypeDefault Value
typePercentage display position, optional values are inner, outerstring'outer'
alignPercentage text alignment, optional values are left, center, rightstring'right'

主题定制

CSS 变量

组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 ConfigProvider 全局配置

名称默认值描述
--wot-progress-bg$filled-content进度条底色
--wot-progress-danger-color$danger-maindanger 进度色
--wot-progress-success-color$success-mainsuccess 进度色
--wot-progress-warning-color$warning-mainwarning 进度色
--wot-progress-color$primary-6默认进度色
--wot-progress-bar-height$n-8外部文案模式进度条高度
--wot-progress-height$n-18内部文案模式组件高度
--wot-progress-label-color$text-main外部文案颜色
--wot-progress-label-width$n-34外部文案宽度
--wot-progress-label-margin-left$spacing-tight外部文案左侧间距
--wot-progress-inner-label-color$text-white内部文案颜色
--wot-progress-inner-zero-bg$primary-2内部 zero 态背景色
--wot-progress-inner-zero-color$text-secondary内部 zero 态文字颜色
--wot-progress-inner-padding$padding-zero $padding-tight内部文案内边距
--wot-progress-label-font-size$typography-label-size-large文案字号
--wot-progress-label-line-height$typography-label-line--height-size-large文案行高
--wot-progress-icon-size$n-18图标字号
--wot-progress-radius$radius-radius-full进度条圆角

Source Code

Documentation
Component

Released under the MIT License.

Released under the MIT License.