Progress
线性、循环和分段进展:状态、梯度和维度。
何时使用
进度显示已完成的可测量工作量及其状态。它适用于加载文件、处理记录和执行计划。如果百分比未知,请使用 Spin;活动动画本身不测量请求。
的百分比、状态和成功部分
percent 设置0到100之间的值。status 选择正常/活动/异常/success;活动动画指的是一条线。 success.percent 单独显示验证成功的部分,success.strokeColor 改变其颜色。
| 问题 | 设置 | 示例 |
|---|---|---|
| 显示数量和状况 | percent、status |
线性进度 |
| 将值放入圆圈 | type="circle" |
界 |
| 添加音阶中断 | type="dashboard", gapDegree |
控制板 |
| 分离选中的部分 | success |
成功的细分市场 |
| 将工作分成几个部分 | steps、rounding |
步骤 |
| 自定义结果文本 | format |
签名 |
format 接收 percent 和 successPercent 并返回文本或片段。 showInfo 隐藏可见标签,但不会覆盖可用的进度条值。对于自定义文本结果,请通过 aria-label 指定 aria-valuetext 和操作名称。
几何、颜色和文本位置
type 选择直线/circle/仪表板。线的尺寸决定了它的宽度和高度;对于圆形,数字决定直径,strokeWidth 决定厚度。不要将 strokeWidth 包裹到线条:此选项已从当前类型中删除。
railColor 装饰未填充区域,strokeColor 装饰填充区域。支持的分段场景允许使用普通颜色、渐变颜色和数组颜色。带渐变的 circle/仪表板忽略了 strokeLinecap,如官方脚本所示。
步骤接受数字或 count/gap 对象。 rounding 指定段值的四舍五入;这不是原始交易数据的四舍五入。 gapPlacement 使用 top/bottom/start/end、percentPosition - 内部/外部和 start/center/end 来标记线。
如果圆的直径设为不超过 20 px 的数值,将指针移到圆上即可看到标签。标签使用提示框的文字颜色。提示框打开前,屏幕阅读器也能读取当前进度。
的更新和设计
该百分比来自应用程序。根据实际工作量进行更新;如果您犯了错误,请保留清晰的解释并重试操作。该演示使用字段和按钮更改值,没有后台模拟计时器。
ConfigProvider.progress 设置一般 class/style 和语义默认值。 Root/body/rail/track/indicator 被格式化为对象或回调; styles 包含 CSS 字符串。进度组件设计令牌(design tokens)通过主题应用并继承常见的版式和颜色。
Prefers-reduced-motion 禁用转换和主动运动。伴随状态更改的文本:异常红色或成功绿色单独不足以解释结果。 bind:nativeElement 提供挂载后的根 div。
非空本地 prefixCls 指定 Progress CSS 类;空字符串和 undefined 继承 ConfigProvider.prefixCls 并带有 -progress 后缀,默认为 ant-progress。百分比、SVG id、语义 styles 和命名空间 CSS 变量在更新时保留。 示例 ConfigProvider 显示公共前缀。
示例
线路状态
正常、活动、错误和已完成的进度。
<script lang="ts">
import { Progress } from '@woodger/antd';
</script>
<style>
.examples {
display: grid;
gap: 16px;
}
</style>
<div class="examples">
<Progress percent={30} aria-label={("共同任务")} />
<Progress percent={50} status="active" aria-label={("活动任务")} />
<Progress percent={70} status="exception" aria-label={("任务错误")} />
<Progress percent={100} aria-label={("已完成任务")} />
<Progress percent={50} showInfo={false} aria-label={("无签名")} />
</div>
<script lang="ts">
import { Progress } from '@woodger/antd';
</script>
<style>
.examples {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 24px;
}
.responsive {
width: 100px;
max-width: 100%;
}
</style>
<div class="examples">
<Progress type="circle" percent={75} aria-label={("循环问题")} />
<Progress type="circle" percent={70} status="exception" aria-label={("圈内错误")} />
<Progress type="circle" percent={100} aria-label={("绕了一圈就完成了")} />
<Progress type="circle" percent={30} size="small" aria-label={("小圆圈")} />
<div class="responsive">
<Progress type="circle" percent={50} size={100} aria-label={("适应圈")} />
</div>
<Progress type="circle" percent={60} size={18} aria-label={("微型圆圈")} />
</div>
细线
尺寸小,适用于狭窄区域。
<script lang="ts">
import { Progress } from '@woodger/antd';
</script>
<style>
.examples {
display: grid;
gap: 16px;
}
</style>
<div class="examples">
<Progress percent={30} size="small" aria-label={("小任务")} />
<Progress percent={50} size="small" status="active" aria-label={("小活动任务")} />
<Progress percent={100} size="small" aria-label={("小准备任务")} />
</div>
变更进度
公共字段控制直线和圆。
<script lang="ts">
import {
Checkbox,
InputNumber,
Progress,
Select,
Slider,
type ProgressStatus
} from '@woodger/antd';
let percent = $state(42.5);
let status = $state<'auto' | ProgressStatus>('auto');
let size = $state<'small' | 'medium'>('medium');
let showInfo = $state(true);
let formatted = $state(false);
const format = (value: number) => `${value.toFixed(1)}%`;
const statuses = ['auto', 'normal', 'active', 'exception', 'success']
.map((value) => ({ value: value as typeof status, label: value }));
let resolvedStatus = $derived(status === 'auto' ? undefined : status);
</script>
<style>
.controls {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
margin-bottom: 24px;
}
.field { width: 150px; }
.preview {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
align-items: center;
gap: 24px;
}
.line { min-width: 0; }
.slider { margin-block: 24px; }
@media (max-width: 575px) {
.preview {
grid-template-columns: minmax(0, 1fr);
justify-items: center;
}
.line {
width: 100%;
}
}
</style>
<div class="controls">
<div class="field"><InputNumber
aria-label={("进度百分比")}
min={0}
max={100}
step={0.5}
value={percent}
onValueChange={(value) => { percent = value ?? 0; }}
/></div>
<div
class="field"
><Select
aria-label={("进展情况")}
bind:value={status}
options={(statuses)}
/></div>
<div class="field"><Select
aria-label={("进度大小")}
bind:value={size}
options={([{ value: 'medium', label: 'medium' }, {
value: 'small',
label: 'small'
}])}
/></div>
<Checkbox
bind:checked={showInfo}
>{("显示进度值")}</Checkbox><Checkbox
bind:checked={formatted}
>{("分数签名进度")}</Checkbox>
</div>
<div class="preview"><div class="line"><Progress
{percent}
{size}
{showInfo}
status={resolvedStatus}
format={formatted ? format : undefined}
aria-label={("线性进度")}
/></div><Progress
type="circle"
{percent}
{size}
{showInfo}
status={resolvedStatus === 'active' ? undefined : resolvedStatus}
format={formatted ? format : undefined}
aria-label={("循环进展")}
/></div>
<div class="slider"><Slider
aria-label={("变更进度百分比")}
min={0}
max={100}
step={0.5}
value={percent}
onValueChange={(value) => { percent = value; }}
/></div>
签名格式
具有单独可用值的文本和片段。
<script lang="ts">
import { Progress } from '@woodger/antd';
</script>
<style>
.examples {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 24px;
}
.label { font-weight: 700; }
</style>
{#snippet label()}<span class="label">{("准备好")}</span>{/snippet}
<div class="examples">
<Progress
type="circle"
percent={75}
format={value => ("" + String((value)) + " 天")}
aria-label={("准备")}
/>
<Progress
type="circle"
percent={100}
format={() => label}
aria-label={("发布")}
aria-valuetext={("准备好")}
/>
</div>
Dashboard
断裂的角度及其逻辑位置。
<script lang="ts">
import { InputNumber, Progress, RadioGroup, type ProgressGapPlacement } from '@woodger/antd';
let gap = $state(75);
let placement = $state<ProgressGapPlacement>('bottom');
</script>
<style>
.settings {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 16px;
margin-bottom: 24px;
}
</style>
<div class="settings">
<InputNumber aria-label={("断裂角")} min={0} max={295} value={gap}
onValueChange={next => { gap = next ?? 0; }} />
<RadioGroup aria-label={("中断位置")} bind:value={placement}
options={(['top', 'bottom', 'start', 'end'])} />
</div>
<Progress
type="dashboard"
percent={75}
gapDegree={gap}
gapPlacement={placement}
aria-label={("进度条")}
/>
成功的细分市场
一般且已成功验证的工作范围。
<script lang="ts">
import { Progress } from '@woodger/antd';
</script>
<style>
.examples {
display: grid;
gap: 24px;
}
.circles {
display: flex;
flex-wrap: wrap;
gap: 24px;
}
</style>
<div class="examples">
<Progress
percent={60}
success={{ percent: 30 }}
aria-label={("下载并检查")}
/>
<div class="circles">
<Progress type="circle" percent={75} success={{ percent: 25 }} aria-label={("带有成功部分的圆圈")} />
<Progress
type="dashboard"
percent={75}
success={{ percent: 25, strokeColor: '#389e0d' }}
aria-label={("具有成功部分的面板")}
/>
</div>
</div>
round
butt
square
行结尾
round、平底和 square。
<script lang="ts">
import { Progress } from '@woodger/antd';
const caps = ['round', 'butt', 'square'] as const;
</script>
<style>
.examples {
display: grid;
gap: 24px;
}
.row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 24px;
}
</style>
<div class="examples">
{#each caps as cap (cap)}
<div><p>{(cap)}</p><div class="row">
<Progress
percent={60}
strokeLinecap={cap}
aria-label={("线 " + String((cap)) + "")}
style="
width: 180px;
max-width: 100%;
"
/>
<Progress type="circle" percent={75} size={80} strokeLinecap={cap} aria-label={("圆圈 " + String((cap)) + "")} />
</div></div>
{/each}
</div>
渐变
线条、圆形和面板之间的颜色过渡。
<script lang="ts">
import { Progress } from '@woodger/antd';
const gradient = { '0%': '#d46b08', '100%': '#389e0d' };
</script>
<style>
.examples {
display: grid;
gap: 24px;
}
.row {
display: flex;
flex-wrap: wrap;
gap: 24px;
}
</style>
<div class="examples">
<Progress percent={80} strokeColor={{ from: '#d46b08', to: '#389e0d' }} aria-label={("线渐变")} />
<div class="row">
<Progress type="circle" percent={90} strokeColor={gradient} aria-label={("圆形渐变")} />
<Progress type="dashboard" percent={90} strokeColor={gradient} aria-label={("面板渐变")} />
</div>
</div>
一步一步进步
线性和圆形段、颜色和圆角。
<script lang="ts">
import { Progress } from '@woodger/antd';
</script>
<style>
.examples {
display: grid;
gap: 24px;
}
.row {
display: flex;
flex-wrap: wrap;
gap: 24px;
}
</style>
<div class="examples">
<Progress percent={60} steps={(5)} aria-label={("五步")} />
<Progress percent={60} steps={(5)} strokeColor={[
'#d46b08',
'#d48806',
'#7cb305',
'#389e0d',
'#08979c'
]} aria-label={("彩色台阶")} />
<Progress percent={59} steps={(5)} rounding={Math.floor} aria-label={("向下舍入")} />
<div class="row">
<Progress
type="circle"
percent={60}
steps={({ count: 5, gap: 4 })}
aria-label={("绕圈的步骤")}
/>
<Progress type="dashboard" percent={60} steps={(8)} aria-label={("面板步骤")} />
</div>
</div>
方面
线的宽度和高度,圆的直径和厚度。
<script lang="ts">
import { Progress } from '@woodger/antd';
</script>
<style>
.examples {
display: grid;
gap: 24px;
}
.row {
display: flex;
flex-wrap: wrap;
gap: 24px;
}
</style>
<div class="examples">
<Progress percent={50} size={[200, 12]} aria-label={("200行12行")} />
<Progress percent={50} size={{ width: '100%', height: 20 }} aria-label={("全线")} />
<div class="row">
<Progress type="circle" percent={50} size={80} strokeWidth={10} aria-label={("80圈")} />
<Progress type="dashboard" percent={50} size={80} strokeWidth={10} aria-label={("小组 80")} />
</div>
</div>
价值定位
线内、线外三种排列方式。
<script lang="ts">
import { Progress } from '@woodger/antd';
const types = ['inner', 'outer'] as const;
const alignments = ['start', 'center', 'end'] as const;
</script>
<style>
.examples {
display: grid;
gap: 24px;
}
</style>
<div class="examples">
{#each types as type (type)}
{#each alignments as align (align)}
<Progress percent={60} percentPosition={{ type, align }} size={type === 'inner' ? [
'100%',
24
] : 'medium'}
aria-label={("" + String((type)) + " " + String((align)) + "")} />
{/each}
{/each}
</div>
Semantic DOM
对象、样式函数和一般提供程序设置。
<script lang="ts">
import { ConfigProvider, Progress } from '@woodger/antd';
</script>
<style>
.examples {
display: grid;
gap: 24px;
}
</style>
<ConfigProvider progress={{ styles: { root: 'padding: 12px' } }}>
<div class="examples">
<Progress percent={60} aria-label={("样式对象")} classNames={{
root: 'progress-object'
}}
styles={{
rail: 'background: #fff1b8',
track: 'background: #d48806',
indicator: 'font-weight: 700'
}} />
<Progress type="circle" percent={70} aria-label={("款式特色")}
classNames={{ root: 'progress-function' }}
styles={({ props }) => ({ indicator: props.percent >= 50 ? 'font-weight: 700' : '' })} />
</div>
</ConfigProvider>
代币和 RTL
嵌套主题中的组件标记。
<script lang="ts">
import { ConfigProvider, Progress } from '@woodger/antd';
</script>
<style>
.examples {
display: grid;
gap: 24px;
}
</style>
<ConfigProvider direction="rtl" theme={{ components: { Progress: {
defaultColor: '#d48806', remainingColor: '#fff1b8', lineBorderRadius: 4,
circleTextColor: '#874d00', circleTextFontSize: '1.1em', circleIconFontSize: '1.4em'
} } }}>
<div class="examples">
<Progress percent={60} aria-label={("专题行")} />
<Progress type="circle" percent={60} aria-label={("专题圈")} />
<Progress type="circle" percent={100} aria-label={("专题图标")} />
</div>
</ConfigProvider>
API
这些脚本映射到 Svelte 包中的 16 个 ant.design 6.7.0 主题和公共类型。
| 主题 | 示例或限制 |
|---|---|
| Progress bar | 线性指示器的五种状态。 |
| Circular progress bar | 通常的循环,错误和成功。 |
| Mini size progress bar | 细线。 |
| Responsive circular progress bar | 容器压缩;直径最大为 20px 的工具提示。 |
| Mini size circular progress bar | small 且数值直径。 |
| Dynamic | 更改百分比、状态和签名。 |
| Custom text format | 文本和简洁的片段。 |
| Dashboard | 断裂的角度和位置。 |
| Progress bar with success segment | 整体运作的成功部分。 |
| Stroke Linecap | 三种结尾形式。 |
| Custom line gradient | 线性和 SVG 渐变。 |
| Progress bar with steps | 阶梯颜色和舍入。 |
| Circular progress bar with steps | 段数和间隙。 |
| Progress size | 数字、数组和大小对象。 |
| Change progress value position | start、center 和 end 位于内部/外部。 |
| Custom semantic dom styling | 带有道具的对象和功能。 |
Progress
| 属性 | 描述 | 类型 | 默认 |
|---|---|---|---|
prefixCls | 直线、圆和进度状态的完整本地 CSS 前缀。空字符串和 undefined 继承ConfigProvider.prefixCls;默认是 ant-progress。 | string | ConfigProvider + -progress |
type | 指示器几何形状。 | line | circle | dashboard | line |
percent | 已完成份额的范围为 0–100。 | number | 0 |
status | 活动仅对线条进行动画处理。 | normal | active | exception | success | 按百分比 |
showInfo | 显示文本或状态图标。 | boolean | true |
format | 文本、数字或片段签名。 | (percent, successPercent?) => ProgressContent | 百分比 |
size | 对象被应用到线上;圆旁边的数字指定直径。 | small | medium | number | [width, height] | {width, height} | medium |
strokeWidth | 圆/仪表板 circle 弧的厚度占 SVG 直径的百分比。对于线条,高度通过 size 指定。 | number | 6 |
strokeColor | 颜色,线性步骤或渐变的颜色数组。 | string | string[] | ProgressGradient | 就主题 |
railColor | 剩余部分的颜色。 | string | 就主题 |
strokeLinecap | 行尾; SVG 渐变使用自己的几何形状。 | round | butt | square | round |
success | 额外成功完成的部分。 | {percent?, strokeColor?} | — |
steps | 细分;gap 指的是圆形台阶。 | number | {count, gap} | — |
rounding | 对活动线性步数进行舍入。 | (value: number) => number | Math.round |
percentPosition | 连续线签名的位置。 | {align: start | center | end, type: inner | outer} | end / outer |
gapDegree | 仪表板断裂角度,0–295。 | number | 仪表板 75 |
gapPlacement | 考虑 RTL 的中断的逻辑位置。 | top | bottom | start | end | bottom |
classNames | 语义槽类。 | ProgressSemanticSlots | callback | — |
styles | CSS 行语义槽;回调接收道具。 | ProgressSemanticSlots | callback | — |
format 返回文本或 Svelte Snippet。对于非标准内容的 Snippet,请单独设置 aria-valuetext。
Semantic DOM
根具有 role=progressbar、aria-valuenow 和范围 0-100。指示器被隐藏,无法重新读取。steps 内没有单独的导轨;circle 使用 SVG。
| Slot | 目的 |
|---|---|
root | 具有可访问值的根。 |
body | 线容器或 SVG。 |
rail | 尾;缺少步骤。 |
track | 填充的部分或段。 |
indicator | 指示器内的文本或图标。 |
注册令牌
ConfigProvider.theme.components.Progress 指定六个组件令牌。对于单个指示器,请使用 strokeColor、railColor 或语义 styles。
| 代币 | 目的 |
|---|---|
defaultColor | 填充部分的颜色。 |
remainingColor | 残留颜色。 |
circleTextColor | 圆形签名颜色。 |
lineBorderRadius | 线舍入。 |
circleTextFontSize | 圆圈文字大小。 |
circleIconFontSize | 圆圈图标大小。 |
| 代币 | 意义 |
|---|---|
colorError | #ff4d4f |
colorSuccess | #52c41a |
colorText | rgba(0,0,0,0.88) |
colorBgContainer | #ffffff |
fontSize | 14 |
lineHeight | 1.5714285714285714 |