I am using Angular Material stepper. Using STEPPER_GLOBAL_OPTIONS, I am able to change the state of the steps like this:
<mat-step [stepControl]="secondFormGroup" optional state="phone">
</mat-step>
However, how do I access the list of these icons? Or, is there any way to use my own?
By default, the step headers will use the create and done icons from the Material design icon set via elements. If you want to provide a different set of icons, you can do so by placing a matStepperIcon for each of the icons that you want to override. The index, active, and optional values of the individual steps are available through template variables:
<mat-vertical-stepper>
<ng-template matStepperIcon="edit">
<mat-icon>insert_drive_file</mat-icon>
</ng-template>
<ng-template matStepperIcon="done">
<mat-icon>done_all</mat-icon>
</ng-template>
<!-- Custom icon with a context variable. -->
<ng-template matStepperIcon="number" let-index="index">
{{index + 10}}
</ng-template>
<!-- Stepper steps go here -->
</mat-vertical-stepper>
Note that you aren't limited to using the mat-icon component when providing custom icons.
https://material.angular.io/components/stepper/overview#overriding-icons
Refer this example angular-material-stepper-example
<!-- changed step icons -->
<ng-template matStepperIcon="home">
<mat-icon>home</mat-icon>
</ng-template>
<ng-template matStepperIcon="form">
<mat-icon>format_align_center</mat-icon>
</ng-template>
<ng-template matStepperIcon="last">
<mat-icon>done_all</mat-icon>
</ng-template>
<mat-step label="First Step" state="home">
<div>
<button mat-button matStepperNext>Continue</button>
</div>
</mat-step>
<mat-step label="Fill out your address" state="form">
<form [formGroup]="formGroup">
<mat-form-field>
<input matInput placeholder="Address" formControlName="secondCtrl" required>
</mat-form-field>
<div>
<button mat-button matStepperPrevious>Back</button>
<button mat-button matStepperNext>Next</button>
</div>
</form>
</mat-step>
<mat-step label="Done" state="last">
You are now done.
<div>
<button mat-button matStepperPrevious>Back</button>
<button mat-button (click)="stepper.reset()">Reset</button>
</div>
</mat-step>
</mat-horizontal-stepper>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With