Progress
Displays bounded progress with status colors, evenly spaced color stops and custom text.
Import
Use <hui-progress> after configuring uni-app easycom. Import public types and functions from @nscode/handy-uni. Ordinary Vue applications install the @nscode/handy-uni/web preview plugin.
Examples
Each example is standalone. Controls show the current value or event result on the page.
<template>
<view>
<hui-space direction="vertical" fill>
<hui-progress
custom-class="hui-space__item"
:percentage="value"
label="上传进度 / Upload progress"
/>
<hui-progress
custom-class="hui-space__item"
:percentage="value"
:color="['#1d4ed8', '#15803d']"
text-inside
:stroke-width="20"
/>
<hui-progress
v-for="status in statuses"
:key="status"
custom-class="hui-space__item"
:percentage="65"
:status="status"
/>
<hui-progress custom-class="hui-space__item" :percentage="value" :show-text="false" />
<hui-progress
custom-class="hui-space__item"
:percentage="value"
:format="(p) => p + ' / 100'"
/>
<hui-button custom-class="hui-space__item" @click="value = (value + 10) % 110"
>推进 / Advance</hui-button
>
</hui-space>
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const value = ref(30)
const statuses = ['success', 'warning', 'exception'] as const
</script>
Props
| Prop | Type | Default | Details |
|---|---|---|---|
percentage | number | 0 | Progress from 0 to 100; invalid values become 0 and out-of-range values are clamped. |
status | ProgressStatus | — | Semantic visual status. |
strokeWidth | number | 6 | Track thickness in px; inside text requires at least 16 px. |
textInside | boolean | false | Places progress text inside the track. |
showText | boolean | true | Displays progress text. |
format | (percentage: number) => string | — | Formats the displayed progress or duration. |
color | ProgressColor | — | Explicit foreground or progress color; arrays provide evenly spaced color stops. |
trackColor | string | — | Explicit track background. |
duration | number | 300 | Animation or display duration in milliseconds; see platform notes for zero. |
label | string | — | Accessible name or text label. |
Root classes and styles use customClass and customStyle. Numbers representing dimensions use px; durations use ms unless explicitly documented.
Events
None.
Slots
| Slot | Scope |
|---|---|
default | { percentage, status } |
Methods
None.
Types
ProgressStatus、ProgressColorFn、ProgressColor、ProgressProps、ProgressEmits.
Theme variables
Override these variables on an ancestor or through the component's customStyle:
| Variable | Default | Details |
|---|---|---|
--hui-progress-inside-color | var(--hui-color-white, #fff) | Color of textInside text when it fits inside the progress bar. |
--hui-progress-text-color | var(--hui-text-color) | Color of outside text; also used when the bar is too short and inside text moves to the start of the track. |
Platform notes
Supports H5, WeChat mini-program, App-vue and ordinary Vue 3 Web through shared platform components. Unit tests do not replace device acceptance; verify touch, screen readers, deactivation and native rendering on each target.
Device smoke checklist.