Steps 步骤条

引导用户按照流程完成任务的导航条。

何时使用

当任务复杂或者存在先后关系时,将其分解成一系列步骤,从而简化任务。

代码演示

基本用法

简单的步骤条。

Steps步骤条 - 图1

  1. import React from 'react';
  2. import ReactDOM from 'react-dom';
  3. import { Steps } from 'choerodon-ui';
  4. const Step = Steps.Step;
  5. ReactDOM.render(
  6. <Steps current={1}>
  7. <Step title="Finished" description="This is a description." />
  8. <Step title="In Progress" description="This is a description." />
  9. <Step title="Waiting" description="This is a description." />
  10. </Steps>,
  11. document.getElementById('container'),
  12. );

迷你版

迷你版的步骤条,通过设置 <Steps size="small"> 启用.

Steps步骤条 - 图2

  1. import React from 'react';
  2. import ReactDOM from 'react-dom';
  3. import { Steps } from 'choerodon-ui';
  4. const Step = Steps.Step;
  5. ReactDOM.render(
  6. <Steps size="small" current={1}>
  7. <Step title="Finished" />
  8. <Step title="In Progress" />
  9. <Step title="Waiting" />
  10. </Steps>,
  11. document.getElementById('container'),
  12. );

带图标的步骤条

通过设置 Steps.Stepicon 属性,可以启用自定义图标。

Steps步骤条 - 图3

  1. import React from 'react';
  2. import ReactDOM from 'react-dom';
  3. import { Steps, Icon } from 'choerodon-ui';
  4. const Step = Steps.Step;
  5. ReactDOM.render(
  6. <Steps>
  7. <Step status="finish" title="Login" icon={<Icon type="person_outline" />} />
  8. <Step status="finish" title="Verification" icon={<Icon type="panorama_vertical" />} />
  9. <Step status="process" title="Pay" icon={<Icon type="schedule" />} />
  10. <Step status="wait" title="Done" icon={<Icon type="tag_faces" />} />
  11. </Steps>,
  12. document.getElementById('container'),
  13. );

步骤切换

通常配合内容及按钮使用,表示一个流程的处理进度。

Steps步骤条 - 图4

  1. import React from 'react';
  2. import ReactDOM from 'react-dom';
  3. import { Steps, Button, message } from 'choerodon-ui';
  4. const Step = Steps.Step;
  5. const steps = [
  6. {
  7. title: 'First',
  8. content: 'First-content',
  9. },
  10. {
  11. title: 'Second',
  12. content: 'Second-content',
  13. },
  14. {
  15. title: 'Last',
  16. content: 'Last-content',
  17. },
  18. ];
  19. class App extends React.Component {
  20. constructor(props) {
  21. super(props);
  22. this.state = {
  23. current: 0,
  24. };
  25. }
  26. next() {
  27. const current = this.state.current + 1;
  28. this.setState({ current });
  29. }
  30. prev() {
  31. const current = this.state.current - 1;
  32. this.setState({ current });
  33. }
  34. render() {
  35. const { current } = this.state;
  36. return (

竖直方向的步骤条

简单的竖直方向的步骤条。

Steps步骤条 - 图5

  1. import React from 'react';
  2. import ReactDOM from 'react-dom';
  3. import { Steps } from 'choerodon-ui';
  4. const Step = Steps.Step;
  5. ReactDOM.render(
  6. <Steps direction="vertical" current={1}>
  7. <Step title="Finished" description="This is a description." />
  8. <Step title="In Progress" description="This is a description." />
  9. <Step title="Waiting" description="This is a description." />
  10. </Steps>,
  11. document.getElementById('container'),
  12. );

竖直方向的小型步骤条

简单的竖直方向的小型步骤条。

Steps步骤条 - 图6

  1. import React from 'react';
  2. import ReactDOM from 'react-dom';
  3. import { Steps } from 'choerodon-ui';
  4. const Step = Steps.Step;
  5. ReactDOM.render(
  6. <Steps direction="vertical" size="small" current={1}>
  7. <Step title="Finished" description="This is a description." />
  8. <Step title="In Progress" description="This is a description." />
  9. <Step title="Waiting" description="This is a description." />
  10. </Steps>,
  11. document.getElementById('container'),
  12. );

步骤运行错误

使用 Steps 的 status 属性来指定当前步骤的状态。

Steps步骤条 - 图7

  1. import React from 'react';
  2. import ReactDOM from 'react-dom';
  3. import { Steps } from 'choerodon-ui';
  4. const Step = Steps.Step;
  5. ReactDOM.render(
  6. <Steps current={1} status="error">
  7. <Step title="Finished" description="This is a description" />
  8. <Step title="In Process" description="This is a description" />
  9. <Step title="Waiting" description="This is a description" />
  10. </Steps>,
  11. document.getElementById('container'),
  12. );

点状步骤条

包含步骤点的进度条。

Steps步骤条 - 图8

  1. import React from 'react';
  2. import ReactDOM from 'react-dom';
  3. import { Steps } from 'choerodon-ui';
  4. const Step = Steps.Step;
  5. ReactDOM.render(
  6. <Steps progressDot current={1}>
  7. <Step title="Finished" description="This is a description." />
  8. <Step title="In Progress" description="This is a description." />
  9. <Step title="Waiting" description="This is a description." />
  10. </Steps>,
  11. document.getElementById('container'),
  12. );

自定义点状步骤条

为点状步骤条增加自定义展示。

Steps步骤条 - 图9

  1. import React from 'react';
  2. import ReactDOM from 'react-dom';
  3. import { Steps, Popover } from 'choerodon-ui';
  4. const Step = Steps.Step;
  5. const customDot = (dot, { status, index }) => (
  6. <Popover
  7. content={
  8. <span>
  9. step {index} status: {status}
  10. </span>
  11. }
  12. >
  13. {dot}
  14. </Popover>
  15. );
  16. ReactDOM.render(
  17. <Steps current={1} progressDot={customDot}>
  18. <Step title="Finished" description="You can hover on the dot." />
  19. <Step title="In Progress" description="You can hover on the dot." />
  20. <Step title="Waiting" description="You can hover on the dot." />
  21. <Step title="Waiting" description="You can hover on the dot." />
  22. </Steps>,
  23. document.getElementById('container'),
  24. );

API

  1. <Steps>
  2. <Step title="第一步" />
  3. <Step title="第二步" />
  4. <Step title="第三步" />
  5. </Steps>

Steps

整体步骤条。

参数说明类型默认值
current指定当前步骤,从 0 开始记数。在子 Step 元素中,可以通过 status 属性覆盖状态number0
direction指定步骤条方向。目前支持水平(horizontal)和竖直(vertical)两种方向stringhorizontal
progressDot点状步骤条,可以设置为一个 functionBoolean or (iconDot, {index, status, title, description}) => ReactNodefalse
size指定大小,目前支持普通(default)和迷你(smallstringdefault
status指定当前步骤的状态,可选 wait process finish errorstringprocess

Steps.Step

步骤条内的每一个步骤。

参数说明类型默认值
description步骤的详情描述,可选string|ReactNode-
icon步骤图标的类型,可选string|ReactNode-
status指定状态。当不配置该属性时,会使用 Steps 的 current 来自动指定状态。可选:wait process finish errorstringwait
title标题string|ReactNode-