Steps 步骤条

显示一个任务的进度;或者引导用户完成某个复杂任务。

规则

  • 应用在离散和时间较长的进度显示,eg:转账进度;如果任务是连续和短暂的,应该使用 Progress 来显示,eg:打开页面。

  • 当任务复杂或者存在先后关系时,将其分解成一系列步骤,从而简化任务,eg:用户注册新账号。

代码演示

步骤条

  1. import { Steps, WingBlank, WhiteSpace } from 'antd-mobile';
  2. const Step = Steps.Step;
  3. const customIcon = () => (
  4. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42 42" className="am-icon am-icon-md">
  5. <g fillRule="evenodd" stroke="transparent" strokeWidth="4">
  6. <path d="M21 0C9.402 0 0 9.402 0 21c0 11.6 9.402 21 21 21s21-9.4 21-21C42 9.402 32.598 0 21 0z" />
  7. <path fill="#FFF" d="M29 18.73c0-.55-.447-1-1-1H23.36l4.428-5.05c.407-.46.407-1.208 0-1.668-.407-.46-1.068-.46-1.476 0l-5.21 5.89-5.21-5.89c-.406-.46-1.067-.46-1.475 0-.406.46-.406 1.207 0 1.667l4.43 5.05H14.23c-.55 0-.998.45-.998 1 0 .554.448.97 1 .97h5.9v3.942h-5.9c-.552 0-1 .448-1 1s.448.985 1 .985h5.9v4.896c0 .552.448 1 1 1 .55 0 .968-.284.968-.836v-5.06H28c.553 0 1-.433 1-.985s-.447-1-1-1h-5.9v-3.94H28c.553 0 1-.418 1-.97z" />
  8. </g>
  9. </svg>
  10. );
  11. ReactDOM.render(
  12. <WingBlank size="lg">
  13. <div className="sub-title">Small size</div>
  14. <WhiteSpace />
  15. <Steps size="small" current={1}>
  16. <Step title="Finished" description="This is description" />
  17. <Step title="In Progress" description="This is description" />
  18. <Step title="Waiting" description="This is description" />
  19. </Steps>
  20. <div className="sub-title">Small size, single line text</div>
  21. <WhiteSpace />
  22. <Steps size="small" current={1}>
  23. <Step title="Finished" />
  24. <Step title="In Progress" />
  25. <Step title="Waiting" />
  26. </Steps>
  27. <div className="sub-title">Default size</div>
  28. <WhiteSpace size="lg" />
  29. <Steps>
  30. <Step status="process" title="Finished" description="This is description" />
  31. <Step status="error" title="Error" description="This is description" />
  32. <Step title="Waiting" description="This is description" />
  33. </Steps>
  34. <div className="sub-title">Customized status </div>
  35. <WhiteSpace size="lg" />
  36. <Steps>
  37. <Step status="finish" title="Step 1" icon={customIcon()} />
  38. <Step status="process" title="Step 2" icon={customIcon()} />
  39. <Step status="error" title="Step 3" icon={customIcon()} />
  40. </Steps>
  41. <div className="sub-title">Customized icon </div>
  42. <WhiteSpace size="lg" />
  43. <Steps current={1}>
  44. <Step title="Step 1" icon={customIcon()} description="This is description" />
  45. <Step title="Step 2" icon={customIcon()} description="This is description" />
  46. <Step title="Step 3" icon={customIcon()} description="This is description" />
  47. </Steps>
  48. <div className="sub-title">Multiple steps </div>
  49. <WhiteSpace size="lg" />
  50. <Steps current={1}>
  51. <Step title="Step 1" icon={customIcon()} />
  52. <Step title="Step 2" icon={customIcon()} />
  53. <Step title="Step 3" status="error" icon={customIcon()} />
  54. <Step title="Step 4" icon={customIcon()} />
  55. </Steps>
  56. </WingBlank>
  57. , mountNode);
  1. .sub-title {
  2. color: #888;
  3. font-size: 14px;
  4. padding: 30px 0 18px 0;
  5. }

水平方向的步骤条

  1. import { Steps, WingBlank, WhiteSpace } from 'antd-mobile';
  2. const Step = Steps.Step;
  3. const steps = [{
  4. title: 'Finished',
  5. description: 'This is description',
  6. }, {
  7. title: 'In Progress',
  8. description: 'This is description',
  9. }, {
  10. title: 'Waiting',
  11. description: 'This is description',
  12. }].map((s, i) => <Step key={i} title={s.title} description={s.description} />);
  13. const customIcon = () => (
  14. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42 42" className="am-icon am-icon-md">
  15. <g fillRule="evenodd" stroke="transparent" strokeWidth="4">
  16. <path d="M21 0C9.402 0 0 9.402 0 21c0 11.6 9.402 21 21 21s21-9.4 21-21C42 9.402 32.598 0 21 0z" />
  17. <path fill="#FFF" d="M29 18.73c0-.55-.447-1-1-1H23.36l4.428-5.05c.407-.46.407-1.208 0-1.668-.407-.46-1.068-.46-1.476 0l-5.21 5.89-5.21-5.89c-.406-.46-1.067-.46-1.475 0-.406.46-.406 1.207 0 1.667l4.43 5.05H14.23c-.55 0-.998.45-.998 1 0 .554.448.97 1 .97h5.9v3.942h-5.9c-.552 0-1 .448-1 1s.448.985 1 .985h5.9v4.896c0 .552.448 1 1 1 .55 0 .968-.284.968-.836v-5.06H28c.553 0 1-.433 1-.985s-.447-1-1-1h-5.9v-3.94H28c.553 0 1-.418 1-.97z" />
  18. </g>
  19. </svg>
  20. );
  21. ReactDOM.render(
  22. <WingBlank mode={20} className="stepsExample">
  23. <div className="sub-title">Horizontal small size</div>
  24. <WhiteSpace />
  25. <Steps current={1} direction="horizontal" size="small">{steps}</Steps>
  26. <div className="sub-title">Horizontal default size</div>
  27. <WhiteSpace />
  28. <Steps current={1} direction="horizontal">{steps}</Steps>
  29. <div className="sub-title">Horizontal customized icon</div>
  30. <WhiteSpace />
  31. <Steps direction="horizontal">
  32. <Step title="Step 1" icon={customIcon()} />
  33. <Step status="error" title="Step 2" icon={customIcon()} />
  34. <Step title="Step 3" icon={customIcon()} />
  35. </Steps>
  36. </WingBlank>
  37. , mountNode);
  1. .stepsExample .timeline.am-steps.am-steps-small
  2. .am-steps-item.am-steps-custom
  3. .am-steps-head-inner > .am-steps-icon {
  4. width: 8px;
  5. height: 8px;
  6. border-radius: 50%;
  7. background-color: #d9dff1;
  8. }
  9. .stepsExample .timeline.am-steps.am-steps-small .am-steps-tail {
  10. top: 3px;
  11. padding: 0 8px;
  12. background-color: transparent;
  13. }
  14. .sub-title {
  15. color: #888;
  16. font-size: 14px;
  17. padding: 30px 0 18px 0;
  18. }

Steps步骤条 - 图1

API

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

Steps

整体步骤条。
属性说明类型默认值
current指定当前步骤,从 0 开始记数。在子 Step 元素中,可以通过 status 属性覆盖状态number0
size尺寸,支持设置小尺寸smallstring-
status指定当前步骤的状态,可选 waitprocessfinisherrorstringprocess
directionstep 样式( RN 目前只支持 vertical )Enum { 'vertical', 'horizontal' }vertical

Steps.Step

步骤条内的每一个步骤。
属性说明类型默认值
status指定状态。当不配置该属性时,会使用 Steps 的 current 来自动指定状态。Enum { 'wait', 'process', 'finish', 'error' }wait
title标题React.Element-
description步骤的详情描述,可选React.Element-
icon步骤图标,可选object/React.Element-