Skip to content

Commit 8ae6ad6

Browse files
raygervaistinayuangao
authored andcommitted
update(stepper): Adds Vertical Stepper example (#10942)
This adds the vertical stepper example to documentation
1 parent cc2bf64 commit 8ae6ad6

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed

src/lib/stepper/stepper.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ styling.
99
### Stepper variants
1010
There are two stepper components: `mat-horizontal-stepper` and `mat-vertical-stepper`. They
1111
can be used the same way. The only difference is the orientation of stepper.
12+
13+
<!-- example(stepper-vertical) -->
14+
1215
`mat-horizontal-stepper` selector can be used to create a horizontal stepper, and
1316
`mat-vertical-stepper` can be used to create a vertical stepper. `mat-step` components need to be
1417
placed inside either one of the two stepper components.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/** No CSS for this example */
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<button mat-raised-button (click)="isLinear = !isLinear" id="toggle-linear">
2+
{{!isLinear ? 'Enable linear mode' : 'Disable linear mode'}}
3+
</button>
4+
<mat-vertical-stepper [linear]="isLinear" #stepper>
5+
<mat-step [stepControl]="firstFormGroup">
6+
<form [formGroup]="firstFormGroup">
7+
<ng-template matStepLabel>Fill out your name</ng-template>
8+
<mat-form-field>
9+
<input matInput placeholder="Last name, First name" formControlName="firstCtrl" required>
10+
</mat-form-field>
11+
<div>
12+
<button mat-button matStepperNext>Next</button>
13+
</div>
14+
</form>
15+
</mat-step>
16+
<mat-step [stepControl]="secondFormGroup">
17+
<form [formGroup]="secondFormGroup">
18+
<ng-template matStepLabel>Fill out your address</ng-template>
19+
<mat-form-field>
20+
<input matInput placeholder="Address" formControlName="secondCtrl" required>
21+
</mat-form-field>
22+
<div>
23+
<button mat-button matStepperPrevious>Back</button>
24+
<button mat-button matStepperNext>Next</button>
25+
</div>
26+
</form>
27+
</mat-step>
28+
<mat-step>
29+
<ng-template matStepLabel>Done</ng-template>
30+
You are now done.
31+
<div>
32+
<button mat-button matStepperPrevious>Back</button>
33+
<button mat-button (click)="stepper.reset()">Reset</button>
34+
</div>
35+
</mat-step>
36+
</mat-vertical-stepper>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {Component} from '@angular/core';
2+
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
3+
4+
/**
5+
* @title Stepper vertical
6+
*/
7+
@Component({
8+
selector: 'stepper-vertical',
9+
templateUrl: 'stepper-vertical-example.html',
10+
styleUrls: ['stepper-vertical-example.css']
11+
})
12+
export class StepperVerticalExample {
13+
isLinear = false;
14+
firstFormGroup: FormGroup;
15+
secondFormGroup: FormGroup;
16+
17+
constructor(private _formBuilder: FormBuilder) { }
18+
19+
ngOnInit() {
20+
this.firstFormGroup = this._formBuilder.group({
21+
firstCtrl: ['', Validators.required]
22+
});
23+
this.secondFormGroup = this._formBuilder.group({
24+
secondCtrl: ['', Validators.required]
25+
});
26+
}
27+
}

0 commit comments

Comments
 (0)