1
1
Angular Material's stepper provides a wizard-like workflow by dividing content into logical steps.
2
2
3
- <!-- example(stepper-overview) -->
4
-
5
3
Material stepper builds on the foundation of the CDK stepper that is responsible for the logic
6
4
that drives a stepped workflow. Material stepper extends the CDK stepper and has Material Design
7
5
styling.
@@ -10,6 +8,8 @@ styling.
10
8
There are two stepper components: ` mat-horizontal-stepper ` and ` mat-vertical-stepper ` . They
11
9
can be used the same way. The only difference is the orientation of stepper.
12
10
11
+ <!-- example(stepper-overview) -->
12
+
13
13
<!-- example(stepper-vertical) -->
14
14
15
15
` mat-horizontal-stepper ` selector can be used to create a horizontal stepper, and
@@ -18,49 +18,31 @@ placed inside either one of the two stepper components.
18
18
19
19
### Labels
20
20
If a step's label is only text, then the ` label ` attribute can be used.
21
- ``` html
22
- <mat-vertical-stepper >
23
- <mat-step label =" Step 1" >
24
- Content 1
25
- </mat-step >
26
- <mat-step label =" Step 1" >
27
- Content 2
28
- </mat-step >
29
- </mat-vertical-stepper >
30
- ```
21
+ <!-- example({"example":"stepper-overview",
22
+ "file":"stepper-overview-example.html",
23
+ "region":"label"}) -->
31
24
32
25
For more complex labels, add a template with the ` matStepLabel ` directive inside the
33
26
` mat-step ` .
34
- ``` html
35
- <mat-vertical-stepper >
36
- <mat-step >
37
- <ng-template matStepLabel >...</ng-template >
38
- ...
39
- </mat-step >
40
- </mat-vertical-stepper >
41
- ```
27
+ <!-- example({"example":"stepper-editable",
28
+ "file":"stepper-editable-example.html",
29
+ "region":"ng-template"}) -->
42
30
43
31
#### Label position
44
32
For ` mat-horizontal-stepper ` it's possible to define the position of the label. ` end ` is the
45
33
default value, while ` bottom ` will place it under the step icon instead of at its side.
46
34
This behaviour is controlled by ` labelPosition ` property.
47
35
48
- <!-- example(stepper-label-position-bottom) -->
36
+ <!-- example({"example":"stepper-label-position",
37
+ "file":"stepper-label-position-example.html",
38
+ "region":"label-position"}) -->
49
39
50
40
### Stepper buttons
51
41
There are two button directives to support navigation between different steps:
52
42
` matStepperPrevious ` and ` matStepperNext ` .
53
- ``` html
54
- <mat-horizontal-stepper >
55
- <mat-step >
56
- ...
57
- <div >
58
- <button mat-button matStepperPrevious >Back</button >
59
- <button mat-button matStepperNext >Next</button >
60
- </div >
61
- </mat-step >
62
- </mat-horizontal-stepper >
63
- ```
43
+ <!-- example({"example":"stepper-label-position",
44
+ "file":"stepper-label-position-example.html",
45
+ "region":"mat-stepper"}) -->
64
46
65
47
### Linear stepper
66
48
The ` linear ` attribute can be set on ` mat-horizontal-stepper ` and ` mat-vertical-stepper ` to create
@@ -122,14 +104,18 @@ are completed.
122
104
If completion of a step in linear stepper is not required, then the ` optional ` attribute can be set
123
105
on ` mat-step ` .
124
106
125
- <!-- example(stepper-optional) -->
107
+ <!-- example({"example":"stepper-optional",
108
+ "file":"stepper-optional-example.html",
109
+ "region":"optional"}) -->
126
110
127
111
128
112
#### Editable step
129
113
By default, steps are editable, which means users can return to previously completed steps and
130
114
edit their responses. ` editable="false" ` can be set on ` mat-step ` to change the default.
131
115
132
- <!-- example(stepper-editable) -->
116
+ <!-- example({"example":"stepper-editable",
117
+ "file":"stepper-editable-example.html",
118
+ "region":"editable"}) -->
133
119
134
120
#### Completed step
135
121
By default, the ` completed ` attribute of a step returns ` true ` if the step is valid (in case of
@@ -142,59 +128,19 @@ set via `<mat-icon>` elements. If you want to provide a different set of icons,
142
128
by placing a ` matStepperIcon ` for each of the icons that you want to override. The ` index ` ,
143
129
` active ` , and ` optional ` values of the individual steps are available through template variables:
144
130
145
- ``` html
146
- <mat-vertical-stepper >
147
- <ng-template matStepperIcon =" edit" >
148
- <mat-icon >insert_drive_file</mat-icon >
149
- </ng-template >
150
-
151
- <ng-template matStepperIcon =" done" >
152
- <mat-icon >done_all</mat-icon >
153
- </ng-template >
154
-
155
- <!-- Custom icon with a context variable. -->
156
- <ng-template matStepperIcon =" number" let-index =" index" >
157
- {{index + 10}}
158
- </ng-template >
159
-
160
- <!-- Stepper steps go here -->
161
- </mat-vertical-stepper >
162
- ```
131
+ <!-- example({"example":"stepper-states",
132
+ "file":"stepper-states-example.html",
133
+ "region":"override-icons"}) -->
163
134
164
135
Note that you aren't limited to using the ` mat-icon ` component when providing custom icons.
165
136
166
137
#### Step States
167
138
You can set the state of a step to whatever you want. The given state by default maps to an icon.
168
139
However, it can be overridden the same way as mentioned above.
169
140
170
- ``` html
171
- <mat-horizontal-stepper >
172
- <mat-step label =" Step 1" state =" phone" >
173
- <p >Put down your phones.</p >
174
- <div >
175
- <button mat-button matStepperNext >Next</button >
176
- </div >
177
- </mat-step >
178
- <mat-step label =" Step 2" state =" chat" >
179
- <p >Socialize with each other.</p >
180
- <div >
181
- <button mat-button matStepperPrevious >Back</button >
182
- <button mat-button matStepperNext >Next</button >
183
- </div >
184
- </mat-step >
185
- <mat-step label =" Step 3" >
186
- <p >You're welcome.</p >
187
- </mat-step >
188
-
189
- <!-- Icon overrides. -->
190
- <ng-template matStepperIcon =" phone" >
191
- <mat-icon >call_end</mat-icon >
192
- </ng-template >
193
- <ng-template matStepperIcon =" chat" >
194
- <mat-icon >forum</mat-icon >
195
- </ng-template >
196
- </mat-horizontal-stepper >
197
- ```
141
+ <!-- example({"example":"stepper-states",
142
+ "file":"stepper-states-example.html",
143
+ "region":"states"}) -->
198
144
199
145
In order to use the custom step states, you must add the ` displayDefaultIndicatorType ` option to
200
146
the global default stepper options which can be specified by providing a value for
0 commit comments