Steps
is a navigation bar that guides users through the steps of a task.
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.
import React from 'react';
import { Steps } from 'antd';
const description = 'This is a description.';
const App: React.FC = () => (
<Steps
current={1}
items={[
{
title: 'Finished',
description,
},
{
title: 'In Progress',
description,
subTitle: 'Left 00:00:08',
},
{
title: 'Waiting',
description,
},
]}
/>
);
export default App;
import React from 'react';
import { Steps } from 'antd';
const App: React.FC = () => (
<Steps
size="small"
current={1}
items={[
{
title: 'Finished',
},
{
title: 'In Progress',
},
{
title: 'Waiting',
},
]}
/>
);
export default App;
import React from 'react';
import { LoadingOutlined, SmileOutlined, SolutionOutlined, UserOutlined } from '@ant-design/icons';
import { Steps } from 'antd';
const App: React.FC = () => (
<Steps
items={[
{
title: 'Login',
status: 'finish',
icon: <UserOutlined />,
},
{
title: 'Verification',
status: 'finish',
icon: <SolutionOutlined />,
},
{
title: 'Pay',
status: 'process',
icon: <LoadingOutlined />,
},
{
title: 'Done',
status: 'wait',
icon: <SmileOutlined />,
},
]}
/>
);
export default App;
import React, { useState } from 'react';
import { Button, message, Steps, theme } from 'antd';
const steps = [
{
title: 'First',
content: 'First-content',
},
{
title: 'Second',
content: 'Second-content',
},
{
title: 'Last',
content: 'Last-content',
},
];
const App: React.FC = () => {
const { token } = theme.useToken();
const [current, setCurrent] = useState(0);
const next = () => {
setCurrent(current + 1);
};
const prev = () => {
setCurrent(current - 1);
};
const items = steps.map((item) => ({ key: item.title, title: item.title }));
const contentStyle: React.CSSProperties = {
lineHeight: '260px',
textAlign: 'center',
color: token.colorTextTertiary,
backgroundColor: token.colorFillAlter,
borderRadius: token.borderRadiusLG,
border: `1px dashed ${token.colorBorder}`,
marginTop: 16,
};
return (
<>
<Steps current={current} items={items} />
<div style={contentStyle}>{steps[current].content}</div>
<div style={{ marginTop: 24 }}>
{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;
import React from 'react';
import { Steps } from 'antd';
const description = 'This is a description.';
const App: React.FC = () => (
<Steps
direction="vertical"
current={1}
items={[
{
title: 'Finished',
description,
},
{
title: 'In Progress',
description,
},
{
title: 'Waiting',
description,
},
]}
/>
);
export default App;
import React from 'react';
import { Steps } from 'antd';
const description = 'This is a description.';
const App: React.FC = () => (
<Steps
direction="vertical"
size="small"
current={1}
items={[
{ title: 'Finished', description },
{
title: 'In Progress',
description,
},
{
title: 'Waiting',
description,
},
]}
/>
);
export default App;
import React from 'react';
import { Steps } from 'antd';
const description = 'This is a description';
const App: React.FC = () => (
<Steps
current={1}
status="error"
items={[
{
title: 'Finished',
description,
},
{
title: 'In Process',
description,
},
{
title: 'Waiting',
description,
},
]}
/>
);
export default App;
import React from 'react';
import { Divider, Steps } from 'antd';
const App: React.FC = () => (
<>
<Steps
progressDot
current={1}
items={[
{
title: 'Finished',
description: 'This is a description.',
},
{
title: 'In Progress',
description: 'This is a description.',
},
{
title: 'Waiting',
description: 'This is a description.',
},
]}
/>
<Divider />
<Steps
progressDot
current={1}
direction="vertical"
items={[
{
title: 'Finished',
description: 'This is a description. This is a description.',
},
{
title: 'Finished',
description: 'This is a description. This is a description.',
},
{
title: 'In Progress',
description: 'This is a description. This is a description.',
},
{
title: 'Waiting',
description: 'This is a description.',
},
{
title: 'Waiting',
description: 'This is a description.',
},
]}
/>
</>
);
export default App;
import React from 'react';
import type { StepsProps } from 'antd';
import { Popover, Steps } from 'antd';
const customDot: StepsProps['progressDot'] = (dot, { status, index }) => (
<Popover
content={
<span>
step {index} status: {status}
</span>
}
>
{dot}
</Popover>
);
const description = 'You can hover on the dot.';
const App: React.FC = () => (
<Steps
current={1}
progressDot={customDot}
items={[
{
title: 'Finished',
description,
},
{
title: 'In Progress',
description,
},
{
title: 'Waiting',
description,
},
{
title: 'Waiting',
description,
},
]}
/>
);
export default App;
import React, { useState } from 'react';
import { Divider, Steps } from 'antd';
const App: React.FC = () => {
const [current, setCurrent] = useState(0);
const onChange = (value: number) => {
console.log('onChange:', value);
setCurrent(value);
};
const description = 'This is a description.';
return (
<>
<Steps
current={current}
onChange={onChange}
items={[
{
title: 'Step 1',
description,
},
{
title: 'Step 2',
description,
},
{
title: 'Step 3',
description,
},
]}
/>
<Divider />
<Steps
current={current}
onChange={onChange}
direction="vertical"
items={[
{
title: 'Step 1',
description,
},
{
title: 'Step 2',
description,
},
{
title: 'Step 3',
description,
},
]}
/>
</>
);
};
export default App;
import React from 'react';
import { Steps } from 'antd';
const description = 'This is a description.';
const App: React.FC = () => (
<Steps
current={1}
percent={60}
items={[
{
title: 'Finished',
description,
},
{
title: 'In Progress',
subTitle: 'Left 00:00:08',
description,
},
{
title: 'Waiting',
description,
},
]}
/>
);
export default App;
import React from 'react';
import { Steps } from 'antd';
const description = 'This is a description.';
const items = [
{
title: 'Finished',
description,
},
{
title: 'In Progress',
description,
},
{
title: 'Waiting',
description,
},
];
const App: React.FC = () => (
<>
<Steps current={1} labelPlacement="vertical" items={items} />
<br />
<Steps current={1} percent={60} labelPlacement="vertical" items={items} />
<br />
<Steps current={1} size="small" labelPlacement="vertical" items={items} />
</>
);
export default App;
import type { StepsProps } from 'antd';
import { Avatar, List, Steps } from 'antd';
import React from 'react';
const data = [
{
title: 'Ant Design Title 1',
current: 0,
},
{
title: 'Ant Design Title 2',
current: 1,
status: 'error',
},
{
title: 'Ant Design Title 3',
current: 2,
},
{
title: 'Ant Design Title 4',
current: 1,
},
];
const items = [
{
title: 'Step 1',
description: 'This is a Step 1.',
},
{
title: 'Step 2',
description: 'This is a Step 2.',
},
{
title: 'Step 3',
description: 'This is a Step 3.',
},
];
const App: React.FC = () => (
<div>
<List
itemLayout="horizontal"
dataSource={data}
renderItem={(item, index) => (
<List.Item>
<List.Item.Meta
avatar={<Avatar src={`https://joesch.moe/api/v1/random?key=${index}`} />}
title={<a href="https://ant.design">{item.title}</a>}
description="Ant Design, a design language for background applications, is refined by Ant UED Team"
/>
<Steps
style={{ marginTop: 8 }}
type="inline"
current={item.current}
status={item.status as StepsProps['status']}
items={items}
/>
</List.Item>
)}
/>
</div>
);
export default App;
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 inline | string | default | inline: 5.0 |
onChange | Trigger when Step is changed | (current) => void | - | |
items | StepItem content | StepItem | [] | 4.24.0 |
type="inline"
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 | |
initial | Set the initial step, counting from 0 | number | 0 | |
status | To specify the status of current step, can be set to one of the following values: wait process finish error | string | process | |
onChange | Trigger when Step is changed | (current) => void | - | |
items | StepItem content. not supported: icon subtitle | StepItem | [] | 4.24.0 |
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 | - |