Steps
Steps
is a navigation bar that guides users through the steps of a task.
When To Use#
When a given task is complicated or has a certain sequence in the series of subtasks, we can decompose it into several steps to make things easier.
Examples
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="first step" />
<Step title="second step" />
<Step title="third step" />
</Steps>
Steps#
The whole of the step bar.
Property | Description | Type | Default | Version |
---|---|---|---|---|
className | Additional class to Steps | string | - | |
current | To set the current step, counting from 0. You can overwrite this state by using status of Step | number | 0 | |
direction | To specify the direction of the step bar, horizontal or vertical | string | horizontal | |
initial | Set the initial step, counting from 0 | number | 0 | |
labelPlacement | Place title and description with horizontal or vertical direction | string | horizontal | |
percent | Progress circle percentage of current step in process status (only works on basic Steps) | number | - | 4.5.0 |
progressDot | Steps with progress dot style, customize the progress dot by setting it to a function. labelPlacement will be vertical | boolean | (iconDot, {index, status, title, description}) => ReactNode | false | |
responsive | Change to vertical direction when screen width smaller than 532px | boolean | true | |
size | To specify the size of the step bar, default and small are currently supported | string | default | |
status | To specify the status of current step, can be set to one of the following values: wait process finish error | string | process | |
type | Type of steps, can be set to one of the following values: default , navigation | string | default | |
onChange | Trigger when Step is changed | (current) => void | - |
Steps.Step#
A single step in the step bar.
Property | Description | Type | Default | Version |
---|---|---|---|---|
description | Description of the step, optional property | ReactNode | - | |
disabled | Disable click | boolean | false | |
icon | Icon of the step, optional property | ReactNode | - | |
status | To specify the status. It will be automatically set by current of Steps if not configured. Optional values are: wait process finish error | string | wait | |
subTitle | Subtitle of the step | ReactNode | - | |
title | Title of the step | ReactNode | - |