Steps
任务阶段:状态、选择、进度、紧凑选项和多步骤形式。
何时使用
步骤显示阶段顺序和当前位置:填写申请、设置或执行流程。它显示状态,但不验证字段或发送请求。要切换独立视图,请使用 Tabs。
索引和进程状态
current - 活动阶段的索引,默认0。前面的阶段通常是完成,当前是处理,后续阶段是等待。 status 设置当前阶段的状态,items.status 允许您覆盖特定项目。
| 脚本 | 设置 | 示例 |
|---|---|---|
| 行动顺序 | items、current |
主要阶段 |
| 现阶段的错误 | status="error" |
错误 |
| 选择可用的阶段 | onChange |
互动舞台 |
| 来自不同值的索引 | initial |
起始索引 |
| 完成申请并进行验证 | 申请状态 | 出价 |
onChange 报告所选索引。更新状态并将其传回 current 状态;这里不提供绑定。initial 偏移初始索引范围。项目或所有步骤的不可访问步骤被设置为 disabled。
字段数据、允许的转换和错误处理属于应用程序。 “下一步”按钮应在更改当前步骤之前检查 current 步骤。重复请求时,保存输入的值,重置时,防止不完整操作产生后期结果。
轴、签名和平台类型
orientation 设置 horizontal/vertical,titlePlacement — 标题相对于图标的位置。title、subTitle 和内容接受 content,包括 Svelte 片段。 type 选择 default、dot、navigation、inline或panel;variant - filled/outlined。
responsive 在视口较窄时切换正常水平视图,而不是在卡片较窄时切换。面板保持水平。宽字幕可能需要局部滚动;它的包装器保留在示例中。
percent 以通常的类型显示当前进程的进度。对于您的图标,首先使用 items.icon; iconRender 允许您自定义通用渲染器。不要期望每种类型同时应用所有常规步骤设置:点、内联和面板都有自己的布局。
maxCount 限制可见点的数量,并用不可访问的椭圆替换隐藏范围。保留原始索引;省略号并不是一个新阶段。外部按钮可以将 current 转移到隐藏范围。
设计与交互
交互性出现在 onChange 或项目处理程序存在的情况下。保存可用的步骤签名;错误图标应补充状态的文本描述。按下允许的阶段不能被视为已经完成或验证。
classNames/styles 配置所有步骤的结构; items.classNames/styles - 一个单独的阶段。styles 包含 CSS 字符串。步骤组件设计令牌(design tokens)控制几何形状和颜色; nativeElement 在挂载后提供 root ol。下面列出了 API 和支持的插槽,其中 语义示例 显示了两个级别的自定义。
ConfigProvider.steps 接受 StepsConfig:class、styles、classNames 和 style。目前,items 和 onChange 仍然是本地 props。回调语义默认获取 current 允许的 props Steps;类被添加在一起,本地语义 styles 覆盖默认值,项目 styles 阐明了单独步骤的设计。对于 root,顺序是:提供者的 styles.root、提供者的 style、本地 styles.root、本地 style。嵌套的 steps={} 替换整个记录。 常规设置 显示优先级而不更改所选步骤。
Timeline 使用步骤的根 class/style,但不继承其语义 classNames/styles。要格式化事件,请设置 ConfigProvider.timeline;空时间线不会重置各个步骤记录。
本地 prefixCls 更改根、状态、阶段和进度的 CSS 类。非空本地前缀优先;空字符串和 undefined 继承 ConfigProvider.prefixCls 并带有 -steps 后缀,默认为 ant-steps。保留 --ant-steps-* / --ant-cmp-steps-* 变量的标识符、选定步骤和命名空间;保留通用的 ant-steps-css-var 标记。语义 classNames/styles 和组件标记以相同的优先级应用。在 iconRender 中,info.components.Icon 组件获得相同的前缀。
本地示例 在标准步骤旁边切换命名空间,保存 current 并支持键盘选择。 示例 ConfigProvider 显示公共 prefix,包括时间轴内步骤的前缀。对于您自己的 CSS 规则,请使用选定的命名空间或语义 classNames。
示例
- 数据完全的填写信息
- 考试进行中检查结果
- 准备好预期的完成动作
基本阶段
当前阶段从零开始计数。前面的阶段完成,接下来的阶段等待;可以用item来确认状况。
<script lang="ts">
import { Steps } from '@woodger/antd';
</script>
<Steps aria-label={("基本阶段")}
current={1}
items={([
{ key: 'data', title: "数据", content: "填写信息" },
{ key: 'review', title: "考试", content: "检查结果" },
{ key: 'done', title: "准备好", content: "完成动作" }
])}
/>
- 数据完全的填写信息
- 考试错误检查结果
- 准备好预期的完成动作
错误状态
status 改变当前阶段。重试示例返回过程;网络请求未得到满足。
<script lang="ts">
import { Steps, Button } from '@woodger/antd';
let status = $state<'error' | 'process'>('error');
</script>
<style>
.controls {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 16px;
margin-bottom: 16px;
}
output {
display: block;
margin-top: 16px;
}
</style>
<div
class="controls"
><Button
onclick={() => { status = status === 'error' ? 'process' : 'error'; }}
>
{(status === 'error' ? "重复检查" : "显示错误")}
</Button></div>
<Steps aria-label={("错误步骤")}
current={1} {status}
items={([
{ key: 'data', title: "数据", content: "填写信息" },
{ key: 'review', title: "考试", content: "检查结果" },
{ key: 'done', title: "准备好", content: "完成动作" }
])}
/>
<output aria-label={("舞台状态")}>{status}</output>
- 数据完全的填写信息
- 考试进行中检查结果
- 准备好预期的完成动作
垂直放置
orientation=vertical 指定垂直顺序。局部 size 优先于整体画廊尺寸。
<script lang="ts">
import { Steps, Checkbox } from '@woodger/antd';
let small = $state(false);
</script>
<style>
.controls {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 16px;
margin-bottom: 16px;
}
</style>
<div
class="controls"
><Checkbox
bind:checked={small}
>{("小型垂直舞台")}</Checkbox></div>
<Steps aria-label={("垂直阶段")}
current={1} orientation="vertical" size={small ? 'small' : 'medium'}
items={([
{ key: 'data', title: "数据", content: "填写信息" },
{ key: 'review', title: "考试", content: "检查结果" },
{ key: 'done', title: "准备好", content: "完成动作" }
])}
/>
- 进行中可用阶段
- 预期的尚不可用
- 预期的完成
舞台选择
onChange 传递索引,应用程序更新 current。在键盘导航期间会跳过无法访问的项目。
<script lang="ts">
import { Steps } from '@woodger/antd';
let current = $state(0);
</script>
<style>
output {
display: block;
margin-top: 16px;
}
</style>
<Steps aria-label={("舞台选择")}
{current} onChange={value => { current = value; }}
items={([
{ key: 'data', title: "数据", content: "可用阶段" },
{ key: 'access', title: "使用权", content: "尚不可用", disabled: true },
{ key: 'done', title: "准备好", content: "完成" }
])}
/>
<output aria-label={("选定阶段")}>{("指数 ")}{current}</output>
- 完全的填写信息
- 进行中检查结果
- 预期的完成动作
面板阶段
type=panel 和 filled/outlined 选项。面板始终是水平的;在窄屏幕上滚动“步骤”。
<script lang="ts">
import { Steps, Checkbox } from '@woodger/antd';
let current = $state(1);
let outlined = $state(false);
</script>
<style>
.controls {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 16px;
margin-bottom: 16px;
}
</style>
<div class="controls">
<Checkbox bind:checked={outlined}>{("轮廓板")}</Checkbox>
</div>
<Steps aria-label={("面板阶段")}
type="panel" {current} variant={outlined ? 'outlined' : 'filled'}
onChange={value => { current = value; }}
items={([
{ key: 'data', title: "数据", content: "填写信息" },
{ key: 'review', title: "考试", content: "检查结果" },
{ key: 'done', title: "准备好", content: "完成动作" }
])}
/>
- 文档完全的
- 考试进行中
- 完成预期的
- 文档完全的
- 考试进行中
- 完成预期的
自定义图标和 iconRender
items.icon 接受片段。 iconRender 获取原始图标和 info;两种形式分别显示。
<script lang="ts">
import type { Snippet } from 'svelte';
import { Steps, type StepsIconInfo } from '@woodger/antd';
</script>
<style>
.stack {
display: grid;
gap: 28px;
}
</style>
{#snippet documentIcon()}
<svg
aria-hidden="true"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.8"
><path
d="M5 3h10l4 4v14H5Zm3 8h8M8 15h8M8 18h5"
/></svg>
{/snippet}
{#snippet checkIcon()}
<svg aria-hidden="true" width="24" height="24" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="1.8"><path d="m5 12 4 4L19 6" /></svg>
{/snippet}
{#snippet iconRender(original: Snippet, info: StepsIconInfo)}
<span title={("阶段 " + String((info.index + 1)) + ": " + String((info.active ? ("当前的") : info.item.status)) + "")}>
{@render original()}
</span>
{/snippet}
<div class="stack">
<Steps current={1} aria-label={("带图标的阶段")} items={([
{ title: "文档", icon: documentIcon }, { title: "考试", icon: checkIcon },
{ title: "完成", icon: checkIcon }
])} />
<Steps
current={1}
{iconRender}
aria-label={("带有图标渲染器的阶段")}
items={([{ title: "文档" }, { title: "考试" }, { title: "完成" }])}
/>
</div>
- 数据完全的公认
- 考试 Текущий этап进行中进行中
- 准备好预期的等待审核
签名和进展
titlePlacement 控制标题的位置。percent 显示当前流程阶段的进度;它不会自动完成该阶段。
<script lang="ts">
import { Steps, type StepsOrientation } from '@woodger/antd';
let percent = $state(40);
let titlePlacement = $state<StepsOrientation>('horizontal');
</script>
<style>
.controls {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 16px;
margin-bottom: 20px;
}
label {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
}
</style>
<div class="controls">
<label>{("签名位置 ")}<select bind:value={titlePlacement}>
<option value="horizontal">
{("边")}
</option>
<option value="vertical">
{("图标下方")}
</option>
</select></label>
<label>{("阶段进展 ")}<input
type="range"
min="0"
max="100"
bind:value={percent}
/>
<output>{percent}%</output>
</label>
</div>
<Steps
current={1}
{titlePlacement}
{percent}
aria-label={("现阶段进展")}
items={([
{ title: "数据", content: "公认" },
{ title: "考试", content: "进行中", subTitle: "现阶段" },
{ title: "准备好", content: "等待审核" }
])}
/>
- 完全的描述 1
- 完全的
- 进行中描述 4
- 预期的
- 预期的描述 8
限制阶段数
maxCount 将隐藏范围折叠成无法访问的椭圆。 current 存储原始列表的索引。
<script lang="ts">
import { Steps, Button } from '@woodger/antd';
let current = $state(3);
</script>
<style>
.controls {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 16px;
margin-bottom: 16px;
}
output {
display: block;
margin-top: 16px;
}
</style>
<div class="controls">
<Button onclick={() => { current = Math.max(0, current - 1); }}>
{("先前的初始阶段")}
</Button>
<Button onclick={() => { current = Math.min(7, current + 1); }}>
{("下一个初始阶段")}
</Button>
</div>
<Steps aria-label={("简化步骤")}
{current} maxCount={3} onChange={value => { current = value; }}
items={([
...Array.from({ length: 8 }, (_, index) => ({
key: index, title: `阶段 ${index + 1}`, content: `描述 ${index + 1}`
}))
])}
/>
<output
aria-label={("初始索引 步骤")}
>{("指数 ")}{current}{(" 从0到7")}</output>
- 完全的填写信息
- 进行中检查结果
- 预期的完成动作
用点代替数字
type=dot 留下紧凑的痕迹。阶段选择通过公共回调更新 current。
<script lang="ts">
import { Steps } from '@woodger/antd';
let current = $state(1);
</script>
<Steps aria-label={("带点的阶段")}
type="dot" {current} onChange={value => { current = value; }}
items={([
{ key: 'data', title: "数据", content: "填写信息" },
{ key: 'review', title: "考试", content: "检查结果" },
{ key: 'done', title: "准备好", content: "完成动作" }
])}
/>
- 填写信息数据完全的填写信息
- 检查结果考试进行中检查结果
- 完成动作准备好预期的完成动作
紧凑型平台
type=inline 适合帖子旁边的简短状态。percent 和自定义图标不用于此类型。
<script lang="ts">
import { Steps } from '@woodger/antd';
</script>
<Steps aria-label={("紧凑型平台")}
type="inline" current={1}
items={([
{ key: 'data', title: "数据", content: "填写信息" },
{ key: 'review', title: "考试", content: "检查结果" },
{ key: 'done', title: "准备好", content: "完成动作" }
])}
/>
项目 | 阶段 |
|---|---|
| Выпуск библиотеки |
|
| Страница проекта |
|
<script lang="ts">
import { Steps, Table } from '@woodger/antd';
interface Task {
key: string;
name: string;
current: number;
}
const tasks: readonly Task[] = [
{ key: 'release', name: "库发布", current: 1 },
{ key: 'homepage', name: "项目页面", current: 2 }
];
</script>
{#snippet stages(task: Task)}
<Steps type="inline" current={task.current} aria-label={("阶段: " + String((task.name)) + "")} items={([
{ title: "准备" }, { title: "考试" }, { title: "准备好" }
])} />
{/snippet}
<Table dataSource={(tasks)} pagination={(false)} caption={("项目阶段")} scroll={{
x: 520
}}
columns={([
{ key: 'name', title: "项目", dataIndex: 'name', width: 220 },
{ key: 'stages', title: "阶段", render: stages }
])}
/>
- 数据完全的
- 考试进行中
- 准备好预期的
组件和项目的语义 styles
全局槽样式根和标头; item.styles 添加一项的设计。 styles 函数对状态做出反应。
<script lang="ts">
import { Steps, Checkbox } from '@woodger/antd';
let bold = $state(true);
</script>
<style>
.controls {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 16px;
margin-bottom: 16px;
}
</style>
<div
class="controls"
><Checkbox
bind:checked={bold}
>{("大胆的步骤标题")}</Checkbox></div>
<Steps aria-label={("已完成的阶段")}
current={1} classNames={{ root: 'semantic-steps-root' }}
styles={() => ({
root: `
padding: 16px;
border: 1px solid var(--ant-color-primary-border);
border-radius: 8px;
`,
itemTitle: `font-weight:${bold ? 700 : 400}`
})}
items={([
{ title: "数据" },
{
title: "考试", classNames: { title: 'semantic-step-title' },
styles: { title: 'text-decoration:underline' }
},
{ title: "准备好" }
])}
/>
- 数据完全的
- 考试进行中
- 准备好预期的
组件代币
本地主题调整正常点和当前点的大小。相邻卡的设置被保存。
<script lang="ts">
import { ConfigProvider, Steps } from '@woodger/antd';
let currentSize = $state(16);
</script>
<style>
label {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
margin-bottom: 20px;
}
</style>
<label>{("当前点大小 ")}<input
type="range"
min="12"
max="20"
bind:value={currentSize}
/>
<output>{currentSize}px</output>
</label>
<ConfigProvider theme={{
cssVar: {}, components: {
Steps: {
dotSize: 10,
dotCurrentSize: currentSize
}
}
}}>
<Steps type="dot" current={1} aria-label={("具有您自己主题的舞台")} items={([
{ title: "数据" }, { title: "考试" }, { title: "准备好" }
])} />
</ConfigProvider>
- 完全的填写信息
- 进行中检查结果
- 预期的完成动作
起始索引
initial 移动编号。 onChange 返回基于 initial 值的索引,而不是本地数组中的位置。
<script lang="ts">
import { Steps } from '@woodger/antd';
let current = $state(6);
</script>
<style>
output {
display: block;
margin-top: 16px;
}
</style>
<Steps aria-label={("具有起始索引的阶段")}
initial={5} {current} onChange={value => { current = value; }}
items={([
{ key: 'data', title: "数据", content: "填写信息" },
{ key: 'review', title: "考试", content: "检查结果" },
{ key: 'done', title: "准备好", content: "完成动作" }
])}
/>
<output
aria-label={("带有偏移步骤的索引")}
>initial: 5; current: {current}</output>
- 完全的舞台描述 1
- 完全的
- 进行中舞台描述 4
- 预期的
- 预期的舞台描述 8
审核选项
已保存切换五种类型 Steps、outline 和 maxCount 的示例。
<script lang="ts">
import { Steps, Select } from '@woodger/antd';
import type { StepsType } from '@woodger/antd';
let type = $state<StepsType>('dot');
let current = $state(3);
</script>
<div style="margin-top:24px">
<Select
aria-label={("步骤选项")}
bind:value={type}
options={(['default', 'dot', 'inline', 'navigation', 'panel']
.map(value => ({ value: value as StepsType, label: value })))}
style="
width: 160px;
margin-bottom: 16px;
"
/>
<Steps
aria-label={("扩展阶段")}
{type}
variant="outlined"
{current}
maxCount={3}
onChange={index => { current = index; }}
items={(Array.from(
{ length: 8 },
(_, index) =>
({ title: `阶段 ${index + 1}`, content: `舞台描述 ${index + 1}` })
))}
/>
</div>
- 完全的填写表格
- 进行中发送前可以更改数据。
- 预期的完成流程
申请步骤
- 进行中填写表格
- 预期的检查您的申请
- 预期的提交您的申请
申请详情
申请步骤
保存的审阅示例:表单检查、编辑、提交错误、重做和重置。
<script lang="ts">
import { onDestroy, tick } from 'svelte';
import {
Button,
Checkbox,
Form,
FormItem,
Input,
Result,
Select,
Steps,
type StepsItem,
type StepsOrientation,
type StepsSize,
type StepsStatus
} from '@woodger/antd';
import { createStepsWizard } from './steps-wizard.model.svelte';
const model = createStepsWizard(message => (message));
let previewCurrent = $state(1);
let orientation = $state<StepsOrientation>('horizontal');
let size = $state<StepsSize>('medium');
let status = $state<StepsStatus>('process');
let clickable = $state(true);
let fail = $state(false);
let panel = $state<HTMLDivElement>();
let active = true;
let action = 0;
let items = $derived<StepsItem[]>(
[
{
key: 'data',
title: "数据",
content: "填写表格",
disabled: model.busy
},
{
key: 'review',
title: "考试",
content: "检查您的申请",
disabled: model.busy || model.unlocked < 1
},
{
key: 'send',
title: "派遣",
content: "提交您的申请",
disabled: model.busy || model.unlocked < 2
}
]
);
onDestroy(() => {
active = false;
action++;
model.destroy();
});
async function focusPanel(token: number) {
await tick();
if (!active || token !== action) {
return;
}
const invalid = panel?.querySelector<HTMLElement>('[aria-invalid="true"]');
(invalid ?? (
model.current === 0
? document.getElementById('steps-example-name')
: panel
))
?.focus({ preventScroll: true });
}
async function goTo(index: number) {
const token = ++action;
const changed = await model.goTo(index);
if (changed || model.validationFailed) await focusPanel(token);
}
function acceptData() { if (model.acceptData()) void focusPanel(++action); }
function review() { if (model.review()) void focusPanel(++action); }
async function send() {
const token = ++action;
if (await model.send(fail) || model.validationFailed) await focusPanel(token);
}
function reset() {
action++;
model.reset();
fail = false;
}
</script>
<style>
.controls {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
}
.workflow-controls { margin-top: 16px; }
.field { width: 180px; }
.preview,
.workflow {
margin-block: 24px;
padding: 20px;
border: 1px solid var(--ant-color-border-secondary);
border-radius: var(--ant-border-radius-lg);
min-width: 0;
}
.workflow:focus-visible {
outline: 2px solid var(--ant-color-primary);
outline-offset: 3px;
}
.form {
max-width: 440px;
margin-inline: auto;
}
.workflow :global(.ant-btn) {
max-width: 100%;
height: auto;
min-height: var(--ant-control-height);
white-space: normal;
}
.workflow :global(.ant-btn-sm) { min-height: var(--ant-control-height-sm); }
.workflow :global(.ant-btn-lg) { min-height: var(--ant-control-height-lg); }
.summary { overflow-wrap: anywhere; }
output {
display: block;
margin-top: 16px;
color: var(--ant-color-text-secondary);
}
</style>
{#snippet previewTitle()}<strong>{("考试")}</strong>{/snippet}
{#snippet previewContent()}
<span>
{("发送前可以更改数据。")}
</span>
{/snippet}
{#snippet completionActions()}<Button type="primary" onclick={() => { void goTo(0); }}>
{("更改申请详细信息")}
</Button>{#if model.status === 'error'}<Button
loading={model.busy}
onclick={() => { void send(); }}
>{("重新提交您的申请")}</Button>{/if}{/snippet}
<div class="controls"><div class="field"><Select
aria-label={("定向步骤")}
bind:value={orientation}
options={([
{ value: 'horizontal', label: "水平" },
{ value: 'vertical', label: "垂直的" }
])}
/></div><div class="field"><Select
aria-label={("尺寸步骤")}
bind:value={size}
options={([{ value: 'medium', label: 'medium' }, {
value: 'small',
label: 'small'
}])}
/></div><div
class="field"
><Select
aria-label={("状态步骤")}
bind:value={status}
options={(['wait', 'process', 'finish', 'error']
.map(value => ({ value: value as StepsStatus, label: value })))}
/></div><Checkbox
bind:checked={clickable}
>{("在步骤中选择一个步骤")}</Checkbox></div>
<div class="preview"><Steps
current={previewCurrent}
{status}
{orientation}
{size}
onChange={clickable ? value => { previewCurrent = value; } : undefined}
aria-label={("预览步骤")}
items={([
{ key: 'data', title: "数据", content: "填写表格" },
{
key: 'review',
title: previewTitle,
subTitle: "发货前",
content: previewContent
},
{ key: 'send', title: "派遣", content: "完成流程" }
])}
/></div>
<h3>{("申请步骤")}</h3>
<Steps
items={(items)}
current={model.current}
status={model.status === 'error' ? 'error' : 'process'}
onChange={index => { void goTo(index); }}
aria-label={("申请阶段")}
/>
<div
class="controls workflow-controls"
><Checkbox
bind:checked={fail}
disabled={model.busy}
>{("发送步骤错误")}</Checkbox><Button
onclick={reset}
>{("重置步骤示例")}</Button></div>
<div
class="workflow"
bind:this={panel}
role="region"
aria-label={("目前申请阶段")}
tabindex="-1"
aria-busy={model.busy || undefined}
>
{#if model.current === 3 || model.status === 'error'}
<Result
status={model.status === 'error' ? 'error' : 'success'}
title={(model.status === 'error'
? "未能逐步提交申请"
: "申请逐步发送")}
subTitle={("" + String((model.submitted?.name)) + ", " + String((model.submitted?.email)) + "")}
headingLevel={4}
extra={(completionActions)}
><p>{(model.status === 'error'
? "字段已保存。取消选中错误框并重新提交。"
: "所有阶段均已完成。您可以返回编辑。")}</p></Result>
{:else if model.current === 0}
<div class="form"><h4>{("申请详情")}</h4><Form
form={model.form}
onFinish={acceptData}
aria-label={("多步骤订单数据")}
><FormItem
name="name"
label={("多步骤申请上的姓名")}
htmlFor="steps-example-name"
help={("参与者姓名。")}
><Input
value={model.form.values.name}
onValueChange={value => model.form.setFieldValue('name', value)}
/></FormItem><FormItem
name="email"
label={("多步骤应用程序中的电子邮件")}
htmlFor="steps-example-email"
help={("name@example.com")}
><Input
type="email"
value={model.form.values.email}
onValueChange={value => model.form.setFieldValue('email', value)}
/></FormItem><Button
type="primary"
htmlType="submit"
loading={model.form.isSubmitting}
>{("检查申请详情")}</Button></Form></div>
{:else if model.current === 1}
<h4>{("应用验证")}</h4><p class="summary">{("姓名: ")}{model
.form.values.name}. Email: {model.form.values.email}.</p><div
class="controls"
><Button
onclick={() => { void goTo(0); }}
>{("返回数据")}</Button><Button
type="primary"
onclick={review}
>{("提交申请")}</Button></div>
{:else}
<h4>{("提交申请")}</h4><p class="summary">{model.form.values.name}, {model
.form.values.email}</p><div
class="controls"
><Button
disabled={model.busy}
onclick={() => { void goTo(1); }}
>{("返回检查")}</Button><Button
type="primary"
loading={model.busy}
onclick={() => { void send(); }}
>{("提交多步骤申请")}</Button></div>
{/if}
</div>
<output aria-label={("步骤示例的结果")}>{("阶段: ")}{(model.current)}{("。状态: ")}{(model.status)}.</output>
- 完全的
- 进行中
- 预期的
- 数据完全的
- 考试进行中
- 准备好预期的
- 数据完全的
- 考试进行中
- 准备好预期的
常规步骤设置
ConfigProvider.steps,当前 props 的回调,本地和项目特定的 styles,重置记录。
<script lang="ts">
import { Checkbox, ConfigProvider, Steps } from '@woodger/antd';
let emphasized = $state(true);
let current = $state(1);
const items = [{ title: "数据" }, { title: "考试" }, { title: "准备好" }];
</script>
<style>
.example, .examples {
display: grid;
gap: 24px;
}
</style>
<div class="example">
<Checkbox bind:checked={emphasized}>{("标题强调步骤")}</Checkbox>
<ConfigProvider steps={({
class: 'shared-steps', style: 'padding: 12px',
classNames: { itemTitle: 'shared-steps-title' },
styles: ({ props }) => ({
itemTitle: props.current === 1 && emphasized
? 'font-weight: 700'
: 'font-weight: 400'
})
})}>
<div class="examples">
<Steps
aria-label={("具有默认值的阶段")}
{current}
items={(items)}
onChange={value => { current = value; }}
/>
<Steps aria-label={("具有地方特色的舞台")} {current}
classNames={{ itemTitle: 'local-steps-title' }}
styles={{ itemTitle: 'font-weight: 400' }}
style="padding: 20px"
items={([...items.slice(0, 2), {
title: "准备好", styles: {
title: 'font-weight: 800'
}
}])} />
<ConfigProvider steps={({})}>
<Steps aria-label={("无默认值的阶段")} {current} items={(items)} />
</ConfigProvider>
</div>
</ConfigProvider>
</div>
- 完全的
- 进行中
- 预期的
- 数据完全的
- 考试进行中
- 准备好预期的
本地 CSS 前缀
更改命名空间、进度、阶段选择和标准邻居;空的 prefixCls 继承 ConfigProvider。
<script lang="ts">
import { Checkbox, Steps } from '@woodger/antd';
let custom = $state(true);
let alternate = $state(false);
let current = $state(1);
const items = [
{ key: 'data', title: "数据" },
{ key: 'review', title: "考试" },
{ key: 'done', title: "准备好" }
];
let prefix = $derived(
custom
? (alternate ? 'project-steps' : 'woodger-steps')
: ''
);
</script>
<style>
.example {
display: grid;
gap: 24px;
}
.controls {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
output { overflow-wrap: anywhere; }
</style>
<div class="example">
<div class="controls">
<Checkbox bind:checked={custom}>{("自定义前缀 步骤")}</Checkbox>
<Checkbox bind:checked={alternate} disabled={!custom}>
{("替代前缀 步骤")}
</Checkbox>
</div>
<Steps
prefixCls={prefix}
aria-label={("带前缀的阶段")}
{current}
items={(items)}
percent={50}
classNames={{ itemTitle: 'prefix-steps-title' }}
styles={{ root: 'padding: 12px' }}
onChange={value => { current = value; }}
/>
<Steps
aria-label={("附近标准舞台")}
{current}
items={(items)}
percent={50}
/>
<output
aria-label={("选择带有前缀的阶段")}
>{("指数 ")}{current}; prefixCls: {(prefix
|| ("来自配置提供者"))}</output>
</div>
API
这些示例是根据当前的 ant.design 页面和已安装包的公共 API 进行检查的。 Props 的完整定义位于 @woodger/antd 中。
| 主题 | 示例或限制 |
|---|---|
| Basic | 当前阶段和自动状态。 |
| Error status | 错误并重试。 |
| Vertical | 方向性和尺寸小。 |
| Clickable | 引导选择、disabled 和键盘。 |
| Panel Steps | 水平面板和 filled/outlined 选项。 |
| With icon | items.icon 和 iconRender。 |
| Title Placement and Progress | 标题、subTitle 和 percent。 |
| Max Count | 在保持索引的同时折叠范围。 |
| Dot Style | 点通过 type="dot"。 |
| Navigation Steps | 导航类型。 |
| Inline Steps | 紧凑状态。 |
| Inline Style Combination | 表中的几个内联序列。 |
| Custom semantic dom styling | 一般和个人语义 styles。 |
| Component config | 通用 class/style、回调语义默认值和本地优先级。 |
| Local CSS prefix | 更改 CSS 前缀,同时保留选择、标识符和标准邻居。 |
| 属性 | 描述 | 类型 | 默认 |
|---|---|---|---|
prefixCls | 根、阶段和进度的完整本地 CSS 前缀。空字符串继承公共前缀; ant-steps 无需配置即可使用。保存令牌的 ID 和命名空间。 | string | ConfigProvider + -steps |
items | 阶段数据;空的条件条目将被跳过。 | readonly (StepsItem | StepsDataItem | false | null | undefined)[] | [] |
current | 当前源索引,考虑到 initial。不提供双向绑定。 | number | 0 |
onChange | 应用程序本身更新 current。如果未设置 item.onClick,则没有回调阶段将提供信息。 | (index: number) => void | — |
initial | 编号和当前阶段的起始索引。 | number | 0 |
status | 当前阶段状态; item.status 覆盖自动。 | 'wait' | 'process' | 'finish' | 'error' | process |
orientation | 水平或垂直的步骤顺序。 | 'horizontal' | 'vertical' | horizontal |
titlePlacement | 放置标题和内容:图标旁边或下方。 | 'horizontal' | 'vertical' | horizontal |
type | 演示类型。 | 'default' | 'dot' | 'inline' | 'navigation' | 'panel' | default |
variant | 填充或轮廓设计。 | 'filled' | 'outlined' | filled |
size | 阶段的大小。 | 'medium' | 'small' | 来自配置提供者 |
responsive | 当视口已经是532px时,将支持的类型切换为 vertical;面板始终是水平的。 | boolean | true |
percent | 当前流程阶段的进展;内联不使用 percent。 | number | — |
maxCount | 将可见阶段限制为三个;隐藏范围被禁用的省略号替换。 | number | — |
iconRender | Snippet 接收 originalElement 和 StepsIconInfo。 items.icon 是更好的选择。 | StepsIconRender | — |
disabled | 禁用阶段选择。 | boolean | 来自配置提供者 |
classNames | 每个阶段的根类和语义槽。 | StepsSemanticSlots | (info) => StepsSemanticSlots | ConfigProvider.steps |
styles | 语义槽 CSS 字符串。 | StepsSemanticSlots | (info) => StepsSemanticSlots | ConfigProvider.steps |
nativeElement | bind:nativeElement 返回根 ol。 | HTMLOListElement | — |
舞台参数
items 支持 key、title、subTitle、content、icon、status、disabled、onClick、class/style 和自定义语义槽。常规的 StepsDataItem 允许在其内容中包含数字、boolean、null 和 Snippet;原始 StepsItem 的 title/icon 保留兼容类型。
ConfigProvider.steps 接受 StepsConfig:class、styles、classNames 和 styles。语义默认值支持具有当前属性的对象或回调。本地 style 优先;嵌套 steps={} 替换整个记录。项目 styles 指定一个单独的阶段; current/items/onChange 仍然是本地道具。
Semantic DOM
根是 ol,role:list,阶段是 li。可选步骤使用本机按钮,当前步骤用 aria-current:step 标记。非交互状态有本地化的标题;选择和移动焦点不会取代应用程序验证。
步骤级别类和 styles 支持 root, item, itemWrapper, itemIcon, itemSection, itemHeader, itemTitle, itemSubtitle, itemContent, itemRail。items 对应于他们 root, wrapper, icon, section, header, title, subtitle, content, rail.
Tab 在可用的阶段按钮之间移动焦点,Enter 和 Space 选择一个阶段。没有带有箭头、Home 和 End 的单独导航。 ConfigProvider.steps 设置 class/style 和语义默认值;状态区域设置通过 locale.steps 继承。本地 prefixCls 更改 CSS 类,保留 ids、键盘和 Steps CSS 变量。
注册令牌
当前的ant.design页面列出了以下11个组件令牌。该包裹接受它们通过 ConfigProvider theme.components.Steps;卡片显示了点的大小。
| 代币 | 目的 |
|---|---|
customIconFontSize | 自定义图标字体大小。 |
customIconSize | 自定义图标容器大小。 |
customIconTop | 自定义图标的垂直偏移。 |
dotCurrentSize | 当前点的大小。 |
dotSize | 常规点的大小。 |
iconFontSize | 图标字体大小。 |
iconSize | 常规图标大小。 |
iconSizeSM | 图标尺寸小。 |
iconTop | 图标的垂直偏移。 |
navArrowColor | 导航箭头颜色。 |
navContentMaxWidth | 导航内容的最大宽度。 |
| 代币 | 当前值 |
|---|---|
colorBgContainer | #ffffff |
colorError | #ff4d4f |
colorErrorBg | #fff2f0 |
colorErrorBgFilledHover | #ffdfdc |
colorErrorHover | #ff7875 |
colorFillTertiary | rgba(0,0,0,0.04) |
colorPrimary | #2f54eb |
colorPrimaryBg | #f0f5ff |
colorPrimaryBgHover | #d6e4ff |
colorPrimaryBorder | #adc6ff |
colorPrimaryHover | #597ef7 |
colorSplit | rgba(5,5,5,0.06) |
colorText | rgba(0,0,0,0.88) |
colorTextDescription | rgba(0,0,0,0.45) |
colorTextDisabled | rgba(0,0,0,0.25) |
colorTextLabel | rgba(0,0,0,0.65) |
colorTextLightSolid | #fff |
colorTextQuaternary | rgba(0,0,0,0.25) |
colorTextSecondary | rgba(0,0,0,0.65) |
borderRadius | 6 |
borderRadiusSM | 4 |
controlHeight | 32 |
controlItemBgHover | rgba(0,0,0,0.04) |
fontFamily | -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
'Noto Color Emoji' |
fontSize | 14 |
fontSizeIcon | 12 |
fontSizeLG | 16 |
fontSizeSM | 12 |
lineHeight | 1.5714285714285714 |
lineHeightLG | 1.5 |
lineHeightSM | 1.6666666666666667 |
lineType | solid |
lineWidth | 1 |
lineWidthBold | 2 |
lineWidthFocus | 3 |
margin | 16 |
marginSM | 12 |
marginXS | 8 |
marginXXS | 4 |
motionDurationMid | 0.2s |
motionDurationSlow | 0.3s |
paddingSM | 12 |
paddingXS | 8 |
paddingXXS | 4 |
FAQ
为什么点击后 current 没有变化?
onChange 传达意图。更新应用程序中的值并将其传回。
如何设置方向、文字和点?
使用 orientation、titlePlacement、items.content 和 type:dot。
maxCount 附带哪些索引?
原始列表的索引。省略号表示范围且不可选择。
为什么水平类型会滚动?
responsive 考虑了视口。对于普通阶段,可以选择 vertical;面板保持水平。
Steps是否存储应用程序的字段和结果?
不会。该数据、操作的验证、重试和取消均由应用程序管理。