A demo can be found at https://cmdap.github.io/ng-wizard/.
The NgWizard component is available as an NPM package. To install the NgWizard package in your Angular project directory run:
$ npm install @cmdap/ng-wizard
Then add a route for the
NgWizardComponentto your Angular router configuration with each step in the wizard as a child route.
For example, your
app-routing.module.tsfile for a wizard with 2 steps can look like this (import statements hidden):;;
Finally, have your step components extend the
NgWizardStepclass or implement the
A minimal step component file can look like this:;;
If you want to use the NgWizard's default Material icons in your project you have to import the material icons stylesheet in your project.
For example, add the following link to your
Custom options can be passed to the NgWizard component via the
data attribute of the wizard route.
Currently the supported configuration options which can be overwritten are (with their default values):
Wizard step options
Custom options for a specific step can be passed as the
of the corresponding child route.
Currently the supported step configuration options which can be overwritten are:
Before navigating, the NgWizard component will call the active step's
Use these methods to save the current state of the step to a service or to perform any other logic you want to execture before leaving the active step.
When a new step is displayed the
ngOnInit method will be called by Angular.
Use this method to initialize the step's data and/or check the user's access rights to this step.
If your step component's state is invalid return
false from your
wsIsValid method. This will cancel the navigation to the next step but
will allow navigating to previous steps.
For any other reason you want to cancel the next or
previous navigation make sure your
This will cancel the Wizard's navigation.
Your step component is responsible for displaying an error message or other reason why the navigation is cancelled.
Entry via URL
Since the NgWizard component utilizes Angular's Routing it is possible
for a user to access any step in the wizard via the URL. If the user is not allowed to access a specific step you can check the
conditions and redirect the user in the step component's
The NgWizard component contains 3 themes you can use and extend, or you can write your own style rules.
The themes are based on Dipu Raj's SmartWizard 4 themes and are called
Because this library uses Angular's style encapsulation you must import the theme or your style rules in the root
styles file of your
You can use one of the provided themes by importing it in your
The provided themes are currently not optimized for responsive designs.
- Improve the responsiveness of the provided themes.
- Improve the component's Accessibility (ARIA attributes, colors and contrasts).
- Add support for more Angular versions
- Make the wizard step methods async
- Add an option to not push step navigation to the browser history
- Add support for setting the wizard's configuration programmatically
If you are willing to contribute to this project you can clone the source code from our github repository.
$ git clone https://github.com/cmdap/ng-wizard.git
You will find a
src folder containing the NgWizard demo project as seen on https://cmdap.github.io/ng-wizard as well as a
projects\ng-wizard folder containing the source code for the ng-wizard component.
In addition to the default Angular commands some useful NPM scripts have been added to the root
||Starts a development server for the demo project. The server will start on http://localhost:4200.|
||Builds the demo project to the
||Runs the Karma/Jasmine tests for the ng-wizard component with code coverage enabled.|
||Runs the linter on the ng-wizard component's source code.|
||Builds the ng-wizard component's source code to an NPM package in the
||Only for project owners. Publishes the ng-wizard package to the NPM repository at https://www.npmjs.com/package/@cmdap/ng-wizard.|