Home:ALL Converter>Angular material stepper not showing properly

Angular material stepper not showing properly

Ask Time:2020-06-15T15:18:11         Author:Pravin Mishra

Json Formatter

This is my HTML code for Angular Material stepper:

<mat-horizontal-stepper class="stepper">
    <mat-step label="Basic" state="cloud_download">
      Step 1
      <button mat-button matStepperNext>Next</button>
    </mat-step>
    <mat-step label="Pixels" state="settings">
      <p>Step 2</p>
      <button mat-button matStepperPrevious>Previous</button>
      <button mat-button matStepperNext>Next</button>
    </mat-step>
    <mat-step label="Creative" state="settings">
      <p>Step 3</p>
      <button mat-button matStepperPrevious>Previous</button>
      <button mat-button matStepperNext>Next</button>
    </mat-step>
    <mat-step label="Targeting" state="settings">
      <p>Step 4</p>
      <button mat-button matStepperPrevious>Previous</button>
      <button mat-button matStepperNext>Next</button>
    </mat-step>
    <mat-step label="Review" state="settings">
      <p>Step 5</p>
      <button mat-button matStepperPrevious>Previous</button>
    </mat-step>
  </mat-horizontal-stepper>

And this is how I imported this in my common import file.

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

/*  Added */
import {MatToolbarModule} from '@angular/material/toolbar';
import {MatIconModule} from '@angular/material/icon';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {MatStepperModule} from '@angular/material/stepper';
import { STEPPER_GLOBAL_OPTIONS } from '@angular/cdk/stepper';
/* */


@NgModule({
  declarations: [],
  imports: [
    CommonModule,
    MatToolbarModule,
    MatIconModule,
    MatCheckboxModule,
    MatStepperModule
  ],
  exports:[
    CommonModule,
    MatToolbarModule,
    MatIconModule,
    MatCheckboxModule,
    MatStepperModule
  ],
  providers: [
    {
      provide: STEPPER_GLOBAL_OPTIONS,
      useValue: { displayDefaultIndicatorType: false }
    }]
})
export class CommonImportsModule { }

But stepper is not showing like what it should show.It is just showing straight line like this:

1_______2________3.

I am using Angular 9 what is the issue I also installed Angular Material and other things from Angular Material works fine.

Author:Pravin Mishra,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/62383191/angular-material-stepper-not-showing-properly
yy