#StepsForm
StepsForm orchestrates nested step forms via a context Provider: each inner form holds a full snapshot of values, then StepsForm merges them after the final submission. Built-in Steps UI and helpers track progress.
StepsForm extends antd
Form.Provider. Serialization of dates (for example convertingdayjsfor submit) follows ProForm’s pipeline, so payloads inonFormFinish/onFormChangeare still the raw Field values managed by Provider.
When steps are split into components, each StepForm owns a separate Form instance, so a single useWatch outside StepsForm cannot watch across every step. Read merged values with stepsFormRef.current?.getAllFieldsValue(), lift the reactive value from onFormChange into parent state, and pass it to other steps for conditional fields or request parameters.
#Basic step flow
import type { ProFormInstance } from '@ant-design/pro-components';
import {
ProCard,
ProForm,
ProFormCheckbox,
ProFormDatePicker,
ProFormDateRangePicker,
ProFormSelect,
ProFormText,
ProFormTextArea,
StepsForm,
} from '@ant-design/pro-components';
import { message } from 'antd';
import { useRef } from 'react';
const waitTime = (time: number = 100) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(true);
}, time);
});
};
const Demo = () => {
const formRef = useRef<ProFormInstance>();
return (
<ProCard>
<StepsForm<{
name: string;
}>
formRef={formRef}
onFinish={async () => {
await waitTime(1000);
message.success('Submission successful');
}}
formProps={{
validateMessages: {
required: 'This field is required',
},
}}
>
<StepsForm.StepForm<{
name: string;
}>
name="steps-from-base"
title="Create Experiment"
stepProps={{
content: 'All basic information is filled in here',
}}
onFinish={async () => {
await waitTime(2000);
return true;
}}
>
<ProFormText
name="name"
label="Experiment Name"
width="md"
tooltip="Up to 24 characters, used as a unique id"
placeholder="Please enter a name"
rules={[{ required: true }]}
/>
<ProFormDatePicker name="date" label="Date" />
<ProFormDateRangePicker name="dateTime" label="Time Range" />
<ProFormTextArea
name="remark"
label="Remarks"
width="lg"
placeholder="Please enter remarks"
/>
</StepsForm.StepForm>
<StepsForm.StepForm<{
checkbox: string;
}>
name="steps-from-checkbox"
title="Set Parameters"
stepProps={{
content: 'Fill in the operation parameters here',
}}
onFinish={async () => {
return true;
}}
>
<ProFormCheckbox.Group
name="checkbox"
label="Migration Type"
width="lg"
options={[
'Structural Migration',
'Full Migration',
'Incremental Migration',
'Full Verification',
]}
/>
<ProForm.Group>
<ProFormText name="dbname" label="Business DB Username" />
<ProFormDatePicker
name="datetime"
label="Record Retention Time"
width="sm"
/>
<ProFormCheckbox.Group
name="checkbox"
label="Migration Type"
options={['Complete LOB', 'Do Not Sync LOB', 'Restricted LOB']}
/>
</ProForm.Group>
</StepsForm.StepForm>
<StepsForm.StepForm
name="steps-from-time"
title="Publish Experiment"
stepProps={{
content: 'Fill in the release criteria here',
}}
>
<ProFormCheckbox.Group
name="checkbox"
label="Deployment Units"
rules={[
{
required: true,
},
]}
options={[
'Deployment Unit 1',
'Deployment Unit 2',
'Deployment Unit 3',
]}
/>
<ProFormSelect
label="Deployment Group Strategy"
name="remark"
rules={[
{
required: true,
},
]}
initialValue="1"
options={[
{
value: '1',
label: 'Strategy One',
},
{ value: '2', label: 'Strategy Two' },
]}
/>
<ProFormSelect
label="Pod Scheduling Strategy"
name="remark2"
initialValue="2"
options={[
{
value: '1',
label: 'Strategy One',
},
{ value: '2', label: 'Strategy Two' },
]}
/>
</StepsForm.StepForm>
</StepsForm>
</ProCard>
);
};
export default () => (
<div style={{ padding: 24 }}>
<Demo />
</div>
);
#Vertical steps layout
import type { ProFormInstance } from '@ant-design/pro-components';
import {
ProCard,
ProForm,
ProFormCheckbox,
ProFormDatePicker,
ProFormDateRangePicker,
ProFormText,
ProFormTextArea,
StepsForm,
} from '@ant-design/pro-components';
import { message } from 'antd';
import { useRef } from 'react';
const waitTime = (time: number = 100) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(true);
}, time);
});
};
const Demo = () => {
const formRef = useRef<ProFormInstance>();
return (
<ProCard>
{/* allowStepSelect:可点击步骤条切换,不触发表单校验 */}
<StepsForm<{
name: string;
}>
allowStepSelect
stepsProps={{
orientation: 'vertical',
}}
formRef={formRef}
onFinish={async () => {
await waitTime(1000);
message.success('提交成功');
}}
formProps={{
validateMessages: {
required: '此项为必填项',
},
}}
>
<StepsForm.StepForm<{
name: string;
}>
name="steps-form-vertical-base"
title="创建实验"
stepProps={{
description: '这里填入的都是基本信息',
}}
onFinish={async () => {
await waitTime(2000);
return true;
}}
>
<ProFormText
name="name"
label="实验名称"
width="md"
tooltip="最长为 24 位,用于标定的唯一 id"
placeholder="请输入名称"
rules={[{ required: true }]}
/>
<ProFormDatePicker name="date" label="日期" />
<ProFormDateRangePicker name="dateTime" label="