11Angular Material's stepper provides a wizard-like workflow by dividing content into logical steps.
22
3- <!-- example(stepper-overview) -->
4-
53Material stepper builds on the foundation of the CDK stepper that is responsible for the logic
64that drives a stepped workflow. Material stepper extends the CDK stepper and has Material Design
75styling.
@@ -10,6 +8,8 @@ styling.
108There are two stepper components: ` mat-horizontal-stepper ` and ` mat-vertical-stepper ` . They
119can be used the same way. The only difference is the orientation of stepper.
1210
11+ <!-- example(stepper-overview) -->
12+
1313<!-- example(stepper-vertical) -->
1414
1515` 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.
1818
1919### Labels
2020If 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"}) -->
3124
3225For more complex labels, add a template with the ` matStepLabel ` directive inside the
3326` 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"}) -->
4230
4331#### Label position
4432For ` mat-horizontal-stepper ` it's possible to define the position of the label. ` end ` is the
4533default value, while ` bottom ` will place it under the step icon instead of at its side.
4634This behaviour is controlled by ` labelPosition ` property.
4735
48- <!-- example(stepper-label-position-bottom) -->
36+ <!-- example({"example":"stepper-label-position",
37+ "file":"stepper-label-position-example.html",
38+ "region":"label-position"}) -->
4939
5040### Stepper buttons
5141There are two button directives to support navigation between different steps:
5242` 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"}) -->
6446
6547### Linear stepper
6648The ` linear ` attribute can be set on ` mat-horizontal-stepper ` and ` mat-vertical-stepper ` to create
@@ -122,14 +104,18 @@ are completed.
122104If completion of a step in linear stepper is not required, then the ` optional ` attribute can be set
123105on ` mat-step ` .
124106
125- <!-- example(stepper-optional) -->
107+ <!-- example({"example":"stepper-optional",
108+ "file":"stepper-optional-example.html",
109+ "region":"optional"}) -->
126110
127111
128112#### Editable step
129113By default, steps are editable, which means users can return to previously completed steps and
130114edit their responses. ` editable="false" ` can be set on ` mat-step ` to change the default.
131115
132- <!-- example(stepper-editable) -->
116+ <!-- example({"example":"stepper-editable",
117+ "file":"stepper-editable-example.html",
118+ "region":"editable"}) -->
133119
134120#### Completed step
135121By 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,
142128by placing a ` matStepperIcon ` for each of the icons that you want to override. The ` index ` ,
143129` active ` , and ` optional ` values of the individual steps are available through template variables:
144130
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"}) -->
163134
164135Note that you aren't limited to using the ` mat-icon ` component when providing custom icons.
165136
166137#### Step States
167138You can set the state of a step to whatever you want. The given state by default maps to an icon.
168139However, it can be overridden the same way as mentioned above.
169140
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"}) -->
198144
199145In order to use the custom step states, you must add the ` displayDefaultIndicatorType ` option to
200146the global default stepper options which can be specified by providing a value for
0 commit comments