Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there an option to change icon for completed step in material-2 stepper

Currently the icon for completed step is 'create'. How can I change it to some other material icon line, like 'Done' ?

<mat-vertical-stepper>
    <mat-step label="Agreement Preparation">
        <p>Agreement preparion is intiated by our side </p>
    </mat-step>
    <mat-step label="Ready for Biometric">
        <p>Agreement preparion is intiated by our side </p>

    </mat-step>
    <mat-step label="Document in Submission">
        <p>Agreement preparion is intiated by our side </p>

    </mat-step>
</mat-vertical-stepper>
like image 648
Aranganathan Avatar asked Oct 16 '17 13:10

Aranganathan


People also ask

How do I change the color of my mat stepper icon?

There does not seem to be option to change color of mat stepper icon, you can use this css as workaround. Custom theme class can be used across application,just wrapp any material component and use color attribute primary,accent or warn as defined in class.

What is stepControl in Mat stepper?

For each mat-step , the stepControl attribute can be set to the top level AbstractControl that is used to check the validity of the step. There are two possible approaches. One is using a single form for stepper, and the other is using a different form for each step.

How many stepper types do we have in general?

There are three main types of stepper motors: Permanent magnet stepper. Variable reluctance stepper. Hybrid synchronous stepper.


2 Answers

The current version of the Material library supports this functionality. (5.2.3+)

Simply include an ng-template that defines your custom icon, and indicate which original icon ('edit' or 'done') you're replacing. The format looks like this:

<ng-template matStepperIcon="edit">
  <mat-icon>face</mat-icon>
</ng-template>

Here, I've replace the 'edit' icon with the material icon for 'face'. (This is a very distinctive icon I used for testing purposes.)

This ng-template goes inside the mat-vertical-stepper or mat-horizontal-stepper.

So, for your example, if you wanted to replace the 'edit' icon with the material icon for 'done', you would do like so:

<mat-vertical-stepper>
    <ng-template matStepperIcon="edit">
      <mat-icon>done</mat-icon>
    </ng-template>

    <mat-step label="Agreement Preparation">
        <p>Agreement prepariaton is initiated by our side </p>
    </mat-step>
    <mat-step label="Ready for Biometrics">
        <p>Agreement preparation is initiated by our side </p>
    </mat-step>
    <mat-step label="Document in Submission">
        <p>Agreement preparion is intiated by our side </p>    
    </mat-step>
</mat-vertical-stepper>

Here is a StackBlitz example showing this in action.

like image 94
Roddy of the Frozen Peas Avatar answered May 07 '23 18:05

Roddy of the Frozen Peas


MatStep has property editable which blocks the step and sets the tick icon "done" to the step header. Run this line once the step is complete:

this.stepper.selected.editable = false;

How to set a step to done having the form unlocked I do not know, but it kind of make sense to indicate that the step is done/complete and lock it. You can again unlock it using editable = true, .next() or .previous() functions.

like image 37
Roc Avatar answered May 07 '23 18:05

Roc