Steps步骤条

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

规则

  • 应用在离散和时间较长的进度显示,eg:转账进度;如果任务是连续和短暂的,应该使用 Progress 来显示,eg:打开页面。
  • 当任务复杂或者存在先后关系时,将其分解成一系列步骤,从而简化任务,eg:用户注册新账号。

代码演示

基本用法

最简单的用法。

  1. import { Component, OnInit } from '@angular/core';
  2. @Component({
  3. selector: 'demo-steps-basic',
  4. template: `
  5. <div class="am-demo-page">
  6. <div style="padding: 15px;font-size: 16px;">步骤条</div>
  7. <div class="am-demo-bd am-wingblank am-wingblank-lg">
  8. <div>
  9. <div class="sub-title">Small size</div>
  10. </div>
  11. <div>
  12. <Steps [size]="'small'" [current]="1">
  13. <Step [title]="'Finished'" [description]="'This is description'"></Step>
  14. <Step [title]="'In Progress'" [description]="'This is description'"></Step>
  15. <Step [title]="'Waiting'" [description]="'This is description'"></Step>
  16. </Steps>
  17. </div>
  18. <div>
  19. <div class="sub-title">Small size, single line text</div>
  20. </div>
  21. <div>
  22. <Steps [size]="'small'" [current]="1">
  23. <Step [title]="'Finished'"></Step>
  24. <Step [title]="'In Progress'"></Step>
  25. <Step [title]="'Waiting'"></Step>
  26. </Steps>
  27. </div>
  28. <div>
  29. <div class="sub-title">Default size</div>
  30. </div>
  31. <div>
  32. <Steps>
  33. <Step [status]="'process'" [title]="'Finished'" [description]="'This is description'"></Step>
  34. <Step [status]="'error'" [title]="'Error'" [description]="'This is description'"></Step>
  35. <Step [title]="'Waiting'" [description]="'This is description'"></Step>
  36. </Steps>
  37. </div>
  38. <div>
  39. <div class="sub-title">Customized status</div>
  40. </div>
  41. <div>
  42. <Steps>
  43. <Step [status]="'finish'" [title]="'Step 1'" [icon]="customIcon"></Step>
  44. <Step [status]="'process'" [title]="'Step 2'" [icon]="customIcon"></Step>
  45. <Step [status]="'error'" [title]="'Step 3'" [icon]="customIcon"></Step>
  46. </Steps>
  47. </div>
  48. <div>
  49. <div class="sub-title">Customized icon</div>
  50. </div>
  51. <div>
  52. <Steps [current]="1">
  53. <Step [title]="'Step 1'" [icon]="customIcon" [description]="'This is description'"></Step>
  54. <Step [title]="'Step 2'" [icon]="customIcon" [description]="'This is description'"></Step>
  55. <Step [title]="'Step 3'" [icon]="customIcon" [description]="'This is description'"></Step>
  56. </Steps>
  57. </div>
  58. <div>
  59. <div class="sub-title">Multiple Steps</div>
  60. </div>
  61. <div>
  62. <Steps [current]="1">
  63. <Step [title]="'Step 1'" [icon]="customIcon"></Step>
  64. <Step [title]="'Step 2'" [icon]="customIcon"></Step>
  65. <Step [title]="'Step 3'" [icon]="customIcon" [status]="'error'"></Step>
  66. <Step [title]="'Step 4'" [icon]="customIcon"></Step>
  67. </Steps>
  68. </div>
  69. </div>
  70. <div style="padding: 15px;font-size: 16px;">水平方向的步骤条</div>
  71. <div class="am-demo-bd am-wingblank am-wingblank-lg">
  72. <div>
  73. <div class="sub-title">Horizontal small size</div>
  74. </div>
  75. <div>
  76. <Steps [size]="'small'" [current]="1" [direction]="'horizontal'">
  77. <Step *ngFor="let v of steps" [title]="v.title" [description]="v.description"></Step>
  78. </Steps>
  79. </div>
  80. <div>
  81. <div class="sub-title">Horizontal default size</div>
  82. </div>
  83. <div>
  84. <Steps [current]="1" [direction]="'horizontal'">
  85. <Step *ngFor="let v of steps" [title]="v.title" [description]="v.description"></Step>
  86. </Steps>
  87. </div>
  88. <div>
  89. <div class="sub-title">Horizontal customized icon</div>
  90. </div>
  91. <div>
  92. <Steps [direction]="'horizontal'">
  93. <Step [title]="'Step 1'" [icon]="customIcon"></Step>
  94. <Step [title]="'Step 2'" [status]="'error'" [icon]="customIcon"></Step>
  95. <Step [title]="'Step 3'" [icon]="customIcon"></Step>
  96. </Steps>
  97. </div>
  98. </div>
  99. </div>
  100. <ng-template #customIcon>
  101. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42 42" class="am-icon am-icon-md">
  102. <g fillRule="evenodd" stroke="transparent" strokeWidth="4">
  103. <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" />
  104. <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" />
  105. </g>
  106. </svg>
  107. </ng-template>
  108. `,
  109. styles: [
  110. `
  111. .sub-title {
  112. color: #888;
  113. font-size: 14px;
  114. padding: 30px 0 18px 0;
  115. }
  116. .am-wingblank,
  117. .am-wingblank-lg {
  118. margin-left: 15px;
  119. margin-right: 15px;
  120. }
  121. .am-button {
  122. display: block;
  123. outline: 0 none;
  124. -webkit-appearance: none;
  125. -webkit-box-sizing: border-box;
  126. box-sizing: border-box;
  127. padding: 0;
  128. text-align: center;
  129. font-size: 18px;
  130. height: 47px;
  131. line-height: 47px;
  132. overflow: hidden;
  133. text-overflow: ellipsis;
  134. word-break: break-word;
  135. white-space: nowrap;
  136. color: #000;
  137. background-color: #fff;
  138. border: 1px solid #ddd;
  139. border-radius: 5px;
  140. margin: 0 15px 15px 15px;
  141. }
  142. `
  143. ]
  144. })
  145. export class DemoStepsBasicComponent implements OnInit {
  146. steps = [];
  147. constructor() {}
  148. ngOnInit() {
  149. this.steps = [
  150. {
  151. title: 'Finished',
  152. description: 'This is description'
  153. },
  154. {
  155. title: 'In Progress',
  156. description: 'This is description'
  157. },
  158. {
  159. title: 'Waiting',
  160. description: 'This is description'
  161. }
  162. ];
  163. }
  164. }

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 样式Enum { 'vertical', 'horizontal' }vertical

Steps.Step

步骤条内的每一个步骤。

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