Getting started with Angular Stepper component

11 Jul 20248 minutes to read

This section explains how to create a simple Stepper, and demonstrate the basic usage of the Stepper module in an Angular environment.

Dependencies

The list of dependencies required to use the Stepper module in your application is given below:

|-- @syncfusion/ej2-angular-navigations
    |-- @syncfusion/ej2-base
    |-- @syncfusion/ej2-popups
    |-- @syncfusion/ej2-navigations
    |-- @syncfusion/ej2-angular-base

Setup Angular environment

You can use Angular CLI to setup your Angular applications. To install Angular CLI use the following command.

npm install -g @angular/cli

Create an Angular application

Start a new Angular application using below Angular CLI command.

ng new my-app
cd my-app

Installing Syncfusion Stepper Package

Syncfusion packages are distributed in npm as @syncfusion scoped packages. You can get all the Angular Syncfusion package from npm link.

Currently, Syncfusion provides two types of package structures for Angular components,

  1. Ivy library distribution package format
  2. Angular compatibility compiler(Angular’s legacy compilation and rendering pipeline) package.

Ivy library distribution package

Syncfusion Angular packages(>=20.2.36) has been moved to the Ivy distribution to support the Angular Ivy rendering engine and the package are compatible with Angular version 12 and above. To download the package use the below command.

Add @syncfusion/ej2-angular-navigations package to the application.

npm install @syncfusion/ej2-angular-navigations --save

Angular compatibility compiled package(ngcc)

For Angular version below 12, you can use the legacy (ngcc) package of the Syncfusion Angular components. To download the ngcc package use the below.

Add @syncfusion/ej2-angular-navigations@ngcc package to the application.

npm install @syncfusion/ej2-angular-navigations@ngcc --save

To mention the ngcc package in the package.json file, add the suffix -ngcc with the package version as below.

@syncfusion/ej2-angular-navigations:"21.1.35-ngcc"

Note: If the ngcc tag is not specified while installing the package, the Ivy Library Package will be installed and this package will throw a warning.

Adding CSS reference

Add Stepper component’s styles as given below in style.css.

@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import '../node_modules/@syncfusion/ej2-popups/styles/material.css';  
@import '../node_modules/@syncfusion/ej2-navigations/styles/material.css';

Adding Syncfusion Stepper component

Modify the template in app.component.ts file with ejs-stepper to render the Stepper component.

import { Component } from "@angular/core";
import {StepperAllModule, StepperModule} from '@syncfusion/ej2-angular-navigations'

@Component({
imports: [ StepperAllModule, StepperModule ],
standalone: true,
selector: "app-root",
template: `<!-- To Render Stepper. -->
  <div>
      <ejs-stepper id="default">
          <e-steps>
              <e-step></e-step>
              <e-step></e-step>
              <e-step></e-step>
              <e-step></e-step>
              <e-step></e-step>
          </e-steps>
      </ejs-stepper>
  </div>`,
})
export class AppComponent { }

Adding Steps

You can define steps by using <e-step> tag directive.

import { Component } from "@angular/core";
import {StepperAllModule, StepperModule} from '@syncfusion/ej2-angular-navigations'

@Component({
imports: [ StepperAllModule, StepperModule ],
standalone: true,
selector: "app-root",
template: `<!-- To Render Stepper. -->
  <div>
      <ejs-stepper id="default">
          <e-steps>
              <e-step></e-step>
              <e-step></e-step>
              <e-step></e-step>
              <e-step></e-step>
              <e-step></e-step>
          </e-steps>
      </ejs-stepper>
  </div>`,
})
export class AppComponent { }

Running the application

Run the application in the browser using the following command:

ng serve

The following example shows a default Stepper component.

import { Component } from "@angular/core";

@Component({
imports: [ StepperAllModule, StepperModule ],


standalone: true,
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent  {
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div class="defaultStepper">
  <ejs-stepper>
    <e-steps>
        <e-step></e-step>
        <e-step></e-step>
        <e-step></e-step>
        <e-step></e-step>
        <e-step></e-step>
    </e-steps>
  </ejs-stepper>
</div>

Configure icon and label

You can define the step icon and label by setting the iconCss and label properties using <e-step> tag directive.

import { Component } from "@angular/core";

@Component({
imports: [ StepperAllModule, StepperModule ],


standalone: true,
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent  {
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div class="iconWithLabel">
  <ejs-stepper>
    <e-steps>
      <e-step label="Cart" iconCss="sf-icon-cart"></e-step>
      <e-step label="Address" iconCss="sf-icon-user"></e-step>
      <e-step label="Delivery" iconCss="sf-icon-transport"></e-step>
      <e-step label="Payment" iconCss="sf-icon-payment"></e-step>
      <e-step label="Ordered" iconCss="sf-icon-success"></e-step>
  </e-steps>
  </ejs-stepper>
</div>
@font-face {
    font-family: 'Default';
    src:
    url(data:application/x-font-ttf;charset=utf-8;base64,AAEAAAAKAIAAAwAgT1MvMj1vSgcAAAEoAAAAVmNtYXCDeIPaAAABmAAAAF5nbHlmEwr+pwAAAggAAAjQaGVhZCYp2+EAAADQAAAANmhoZWEIUQQHAAAArAAAACRobXR4GAAAAAAAAYAAAAAYbG9jYQhUBlAAAAH4AAAADm1heHABFgErAAABCAAAACBuYW1luF5THQAACtgAAAIlcG9zdJ8LuoMAAA0AAAAAbwABAAAEAAAAAFwEAAAAAAAD9AABAAAAAAAAAAAAAAAAAAAABgABAAAAAQAArxT6wV8PPPUACwQAAAAAAOGLy6UAAAAA4YvLpQAAAAAD9AOaAAAACAACAAAAAAAAAAEAAAAGAR8ABgAAAAAAAgAAAAoACgAAAP8AAAAAAAAAAQQAAZAABQAAAokCzAAAAI8CiQLMAAAB6wAyAQgAAAIABQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUGZFZABA5wLnFQQAAAAAXAQAAAAAAAABAAAAAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAAAAAAAgAAAAMAAAAUAAMAAQAAABQABABKAAAADAAIAAIABOcC5wbnCOcQ5xX//wAA5wLnBucI5xDnFf//AAAAAAAAAAAAAAABAAwADAAMAAwADAAAAAEABAACAAMABQAAAAAAAAEQAiwC3AQkBGgAAAAFAAAAAAP0A18APwB/AIkAxgDrAAABHw8/Dy8OKwEPDQUfDz8PLw4rAQ8NAR8FFSM1JxEfBz8OOwEfDjM/BzUnIw8GATM/Dx8PMxEhAq8BAQIEBAUFBwYICAgJCQoKCgkKCAkIBwcHBQUEAwMBAQEBAwMEBQUHBwcICQg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5lcmF0ZWQgdXNpbmcgU3luY2Z1c2lvbiBNZXRybyBTdHVkaW93d3cuc3luY2Z1c2lvbi5jb20AIABEAGUAZgBhAHUAbAB0AFIAZQBnAHUAbABhAHIARABlAGYAYQB1AGwAdABEAGUAZgBhAHUAbAB0AFYAZQByAHMAaQBvAG4AIAAxAC4AMABEAGUAZgBhAHUAbAB0AEYAbwBuAHQAIABnAGUAbgBlAHIAYQB0AGUAZAAgAHUAcwBpAG4AZwAgAFMAeQBuAGMAZgB1AHMAaQBvAG4AIABNAGUAdAByAG8AIABTAHQAdQBkAGkAbwB3AHcAdwAuAHMAeQBuAGMAZgB1AHMAaQBvAG4ALgBjAG8AbQAAAAACAAAAAAAAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYBAgEDAQQBBQEGAQcADXRyYW5zcG9ydC12YW4LdXNlci1tb2RpZnkRc2hvcHBpbmctY2FydF8wMS0Lc3BlbmQtbW9uZXkFY2hlY2sAAAA=) format('truetype');
    font-weight: normal;
    font-style: normal;
}

.iconWithLabel {
    margin-top: 30px;
    padding: 30px;
}

.iconWithLabel [class^="sf-icon-"], .iconWithLabel [class*=" sf-icon-"] {
    font-family: 'Default' !important;
    speak: none;
    font-style: normal;
    font-weight: normal;
    font-variant: normal;
    text-transform: none;
    line-height: inherit;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.iconWithLabel .sf-icon-cart:before { content: "\e710"; }
.iconWithLabel .sf-icon-user:before { content: "\e708"; }
.iconWithLabel .sf-icon-transport:before { content: "\e702"; }
.iconWithLabel .sf-icon-payment:before { content: "\e706"; }
.iconWithLabel .sf-icon-success:before { content: "\e715"; }