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]="'loading'"></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]="customTitle" [icon]="customIcon" [description]="customDescription"></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 #customTitle>
  101. <div>Step 3</div>
  102. </ng-template>
  103. <ng-template #customDescription>
  104. <div>'This is description'</div>
  105. </ng-template>
  106. <ng-template #customIcon>
  107. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42 42" class="am-icon am-icon-md">
  108. <g fillRule="evenodd" stroke="transparent" strokeWidth="4">
  109. <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" />
  110. <path
  111. fill="#FFF"
  112. 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"
  113. />
  114. </g>
  115. </svg>
  116. </ng-template>
  117. `,
  118. styles: [
  119. `
  120. .sub-title {
  121. color: #888;
  122. font-size: 14px;
  123. padding: 30px 0 18px 0;
  124. }
  125. .am-wingblank,
  126. .am-wingblank-lg {
  127. margin-left: 15px;
  128. margin-right: 15px;
  129. }
  130. .am-button {
  131. display: block;
  132. outline: 0 none;
  133. -webkit-appearance: none;
  134. -webkit-box-sizing: border-box;
  135. box-sizing: border-box;
  136. padding: 0;
  137. text-align: center;
  138. font-size: 18px;
  139. height: 47px;
  140. line-height: 47px;
  141. overflow: hidden;
  142. text-overflow: ellipsis;
  143. word-break: break-word;
  144. white-space: nowrap;
  145. color: #000;
  146. background-color: #fff;
  147. border: 1px solid #ddd;
  148. border-radius: 5px;
  149. margin: 0 15px 15px 15px;
  150. }
  151. `
  152. ]
  153. })
  154. export class DemoStepsBasicComponent implements OnInit {
  155. steps = [];
  156. constructor() {}
  157. ngOnInit() {
  158. this.steps = [
  159. {
  160. title: 'Finished',
  161. description: 'This is description'
  162. },
  163. {
  164. title: 'In Progress',
  165. description: 'This is description'
  166. },
  167. {
  168. title: 'Waiting',
  169. description: 'This is description'
  170. }
  171. ];
  172. }
  173. }

Steps步骤条 - 图1

API

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

Steps

整体步骤条。

参数说明类型默认值
[current]指定当前步骤,从 0 开始记数。在子 Step 元素中,可以通过 status 属性覆盖状态number0
[size]尺寸large | ‘small’-
[status]指定当前步骤的状态‘wait’ | ‘process’ | ‘finish’ | ‘error’‘process’
[direction]step的方向‘vertical’ | ‘horizontal’‘vertical’

Step

步骤条内的每一个步骤。

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