Steps步骤条
引导用户按照流程完成任务的导航条。
何时使用#
当任务复杂或者存在先后关系时,将其分解成一系列步骤,从而简化任务。
代码演示
Finished
This is a description.
In Progress
Left 00:00:08
This is a description.
Waiting
This is a description.
TypeScript
JavaScript
import { Steps } from 'infrad';
import React from 'react';
const { Step } = Steps;
const App: React.FC = () => (
<Steps current={1}>
<Step title="Finished" description="This is a description." />
<Step title="In Progress" subTitle="Left 00:00:08" description="This is a description." />
<Step title="Waiting" description="This is a description." />
</Steps>
);
export default App;
Finished
In Progress
Waiting
TypeScript
JavaScript
import { Steps } from 'infrad';
import React from 'react';
const { Step } = Steps;
const App: React.FC = () => (
<Steps size="small" current={1}>
<Step title="Finished" />
<Step title="In Progress" />
<Step title="Waiting" />
</Steps>
);
export default App;
Login
Verification
Pay
Done
TypeScript
JavaScript
import { LoadingOutlined, SmileOutlined, SolutionOutlined, UserOutlined } from 'infra-design-icons';
import { Steps } from 'infrad';
import React from 'react';
const { Step } = Steps;
const App: React.FC = () => (
<Steps>
<Step status="finish" title="Login" icon={<UserOutlined />} />
<Step status="finish" title="Verification" icon={<SolutionOutlined />} />
<Step status="process" title="Pay" icon={<LoadingOutlined />} />
<Step status="wait" title="Done" icon={<SmileOutlined />} />
</Steps>
);
export default App;
First
Second
Last
First-content
TypeScript
JavaScript
import { Button, message, Steps } from 'infrad';
import React, { useState } from 'react';
const { Step } = Steps;
const steps = [
{
title: 'First',
content: 'First-content',
},
{
title: 'Second',
content: 'Second-content',
},
{
title: 'Last',
content: 'Last-content',
},
];
const App: React.FC = () => {
const [current, setCurrent] = useState(0);
const next = () => {
setCurrent(current + 1);
};
const prev = () => {
setCurrent(current - 1);
};
return (
<>
<Steps current={current}>
{steps.map(item => (
<Step key={item.title} title={item.title} />
))}
</Steps>
<div className="steps-content">{steps[current].content}</div>
<div className="steps-action">
{current < steps.length - 1 && (
<Button type="primary" onClick={() => next()}>
Next
</Button>
)}
{current === steps.length - 1 && (
<Button type="primary" onClick={() => message.success('Processing complete!')}>
Done
</Button>
)}
{current > 0 && (
<Button style={{ margin: '0 8px' }} onClick={() => prev()}>
Previous
</Button>
)}
</div>
</>
);
};
export default App;
.steps-content {
min-height: 200px;
margin-top: 16px;
padding-top: 80px;
text-align: center;
background-color: #fafafa;
border: 1px dashed #e9e9e9;
border-radius: 2px;
}
.steps-action {
margin-top: 24px;
}
Finished
This is a description.
In Progress
This is a description.
Waiting
This is a description.
TypeScript
JavaScript
import { Steps } from 'infrad';
import React from 'react';
const { Step } = Steps;
const App: React.FC = () => (
<Steps direction="vertical" current={1}>
<Step title="Finished" description="This is a description." />
<Step title="In Progress" description="This is a description." />
<Step title="Waiting" description="This is a description." />
</Steps>
);
export default App;
Finished
This is a description.
In Progress
This is a description.
Waiting
This is a description.
TypeScript
JavaScript
import { Steps } from 'infrad';
import React from 'react';
const { Step } = Steps;
const App: React.FC = () => (
<Steps direction="vertical" size="small" current={1}>
<Step title="Finished" description="This is a description." />
<Step title="In Progress" description="This is a description." />
<Step title="Waiting" description="This is a description." />
</Steps>
);
export default App;
In Process
This is a description
Waiting
This is a description
TypeScript
JavaScript
import { Steps } from 'infrad';
import React from 'react';
const { Step } = Steps;
const App: React.FC = () => (
<Steps current={1} status="error">
<Step title="Finished" description="This is a description" />
<Step title="In Process" description="This is a description" />
<Step title="Waiting" description="This is a description" />
</Steps>
);
export default App;
Finished
This is a description.
In Progress
This is a description.
Waiting
This is a description.
Finished
This is a description. This is a description.
Finished
This is a description. This is a description.
In Progress
This is a description. This is a description.
Waiting
This is a description.
Waiting
This is a description.
TypeScript
JavaScript
import { Divider, Steps } from 'infrad';
import React from 'react';
const { Step } = Steps;
const App: React.FC = () => (
<>
<Steps progressDot current={1}>
<Step title="Finished" description="This is a description." />
<Step title="In Progress" description="This is a description." />
<Step title="Waiting" description="This is a description." />
</Steps>
<Divider />
<Steps progressDot current={1} direction="vertical">
<Step title="Finished" description="This is a description. This is a description." />
<Step title="Finished" description="This is a description. This is a description." />
<Step title="In Progress" description="This is a description. This is a description." />
<Step title="Waiting" description="This is a description." />
<Step title="Waiting" description="This is a description." />
</Steps>
</>
);
export default App;
Finished
You can hover on the dot.
In Progress
You can hover on the dot.
Waiting
You can hover on the dot.
Waiting
You can hover on the dot.
TypeScript
JavaScript
import type { StepsProps } from 'infrad';
import { Popover, Steps } from 'infrad';
import React from 'react';
const { Step } = Steps;
const customDot: StepsProps['progressDot'] = (dot, { status, index }) => (
<Popover
content={
<span>
step {index} status: {status}
</span>
}
>
{dot}
</Popover>
);
const App: React.FC = () => (
<Steps current={1} progressDot={customDot}>
<Step title="Finished" description="You can hover on the dot." />
<Step title="In Progress" description="You can hover on the dot." />
<Step title="Waiting" description="You can hover on the dot." />
<Step title="Waiting" description="You can hover on the dot." />
</Steps>
);
export default App;
Step 1
This is a description.
Step 2
This is a description.
Step 3
This is a description.
Step 1
This is a description.
Step 2
This is a description.
Step 3
This is a description.
TypeScript
JavaScript
import { Divider, Steps } from 'infrad';
import React, { useState } from 'react';
const { Step } = Steps;
const App: React.FC = () => {
const [current, setCurrent] = useState(0);
const onChange = (value: number) => {
console.log('onChange:', current);
setCurrent(value);
};
return (
<>
<Steps current={current} onChange={onChange}>
<Step title="Step 1" description="This is a description." />
<Step title="Step 2" description="This is a description." />
<Step title="Step 3" description="This is a description." />
</Steps>
<Divider />
<Steps current={current} onChange={onChange} direction="vertical">
<Step title="Step 1" description="This is a description." />
<Step title="Step 2" description="This is a description." />
<Step title="Step 3" description="This is a description." />
</Steps>
</>
);
};
export default App;
Finished
This is a description.
In Progress
Left 00:00:08
This is a description.
Waiting
This is a description.
TypeScript
JavaScript
import { Steps } from 'infrad';
import React from 'react';
const { Step } = Steps;
const App: React.FC = () => (
<Steps current={1} percent={60}>
<Step title="Finished" description="This is a description." />
<Step title="In Progress" subTitle="Left 00:00:08" description="This is a description." />
<Step title="Waiting" description="This is a description." />
</Steps>
);
export default App;
API#
<Steps>
<Step title="第一步" />
<Step title="第二步" />
<Step title="第三步" />
</Steps>
Steps#
整体步骤条。
参数 | 说明 | 类型 | 默认值 | 版本 |
---|---|---|---|---|
className | 步骤条类名 | string | - | |
current | 指定当前步骤,从 0 开始记数。在子 Step 元素中,可以通过 status 属性覆盖状态 | number | 0 | |
direction | 指定步骤条方向。目前支持水平(horizontal )和竖直(vertical )两种方向 | string | horizontal | |
initial | 起始序号,从 0 开始记数 | number | 0 | |
labelPlacement | 指定标签放置位置,默认水平放图标右侧,可选 vertical 放图标下方 | string | horizontal | |
percent | 当前 process 步骤显示的进度条进度(只对基本类型的 Steps 生效) | number | - | 4.5.0 |
progressDot | 点状步骤条,可以设置为一个 function,labelPlacement 将强制为 vertical | boolean | (iconDot, {index, status, title, description}) => ReactNode | false | |
responsive | 当屏幕宽度小于 532px 时自动变为垂直模式 | boolean | true | |
size | 指定大小,目前支持普通(default )和迷你(small ) | string | default | |
status | 指定当前步骤的状态,可选 wait process finish error | string | process | |
type | 步骤条类型,有 default 和 navigation 两种 | string | default | |
onChange | 点击切换步骤时触发 | (current) => void | - |
Steps.Step#
步骤条内的每一个步骤。
参数 | 说明 | 类型 | 默认值 | 版本 |
---|---|---|---|---|
description | 步骤的详情描述,可选 | ReactNode | - | |
disabled | 禁用点击 | boolean | false | |
icon | 步骤图标的类型,可选 | ReactNode | - | |
status | 指定状态。当不配置该属性时,会使用 Steps 的 current 来自动指定状态。可选:wait process finish error | string | wait | |
subTitle | 子标题 | ReactNode | - | |
title | 标题 | ReactNode | - |