Overview angular-archwizard
This project contains a functional module with a wizard component and some supportive components and directives for Angular version 9 or later.
Build
Run npm run build to build the project. The build artifacts will be stored in the dist/ directory.
Running unit tests
Run npm test to execute the unit tests via Karma.
Compatibility
Latest angular-archwizard is compatible with Angular 9+.
Older versions of angular-archwizard can be used together with older versions of Angular.
The following table shows which version of angular-archwizard has been built with which Angular version:
angular-archwizard version |
Angular version |
3.0.0 |
Angular 5 |
4.0.0 |
Angular 7 |
5.0.1 |
Angular 8 |
6.1.0 |
Angular 9 |
7.0.0 |
Angular 11 |
Gitpod
angular-archwizard can be developed with Gitpod, a free one-click online IDE for GitHub:

Installation
Step 1: Install angular-archwizard
angular-archwizard is available as a NPM package. To install angular-archwizard in your project directory run:
$ npm install --save angular-archwizard
Step 2: Import the ArchwizardModule
After installation you can import angular-archwizard into your Angular project by adding the ArchwizardModule to your module declaration as follows:
import { ArchwizardModule } from 'angular-archwizard';
@NgModule({
imports: [
ArchwizardModule
],
})
export class Module { }
Step 3: Include styles
To allow customization, angular-archwizard bundles CSS styles separately. If you are using Angular CLI, import them into your styles.css...
@import '../node_modules/angular-archwizard/styles/archwizard.css';
...or include them into angular.json:
{
// ...
"styles": [
"node_modules/angular-archwizard/styles/archwizard.css",
"src/styles.css"
]
// ...
}
If you are using SCSS, you can include the styles in the form of a .scss file: node_modules/angular-archwizard/styles/archwizard.scss.
This way you can easily customize wizard's appearance by tweaking SCSS variables as described in Styles Customization.
How to use the wizard
To use this wizard component in an angular project simply add a aw-wizard component to the html template of your component:
<aw-wizard>
<aw-wizard-step stepTitle="Title of step 1">
Content of Step 1
<button type="button" awNextStep>Next Step</button>
<button type="button" [awGoToStep]="{stepIndex: 2}">Go directly to third Step</button>
</aw-wizard-step>
<aw-wizard-step stepTitle="Title of step 2" awOptionalStep>
Content of Step 2
<button type="button" awPreviousStep>Go to previous step</button>
<button type="button" awNextStep>Go to next step</button>
</aw-wizard-step>
<aw-wizard-step stepTitle="Title of step 3">
Content of Step 3
<button type="button" awPreviousStep>Previous Step</button>
<button type="button" (click)="finishFunction()">Finish</button>
</aw-wizard-step>
</aw-wizard>
Components
<aw-wizard>
The <aw-wizard> environment is the environment in which you define the steps belonging to your wizard.
In addition to the contained wizard steps, angular-archwizard enables you to define the location and the layout of the navigation bar inside your wizard.
To set the location, the layout of the navigation bar and many other settings, you can pass the following parameters to the aw-wizard component:
[navBarLocation]
The location of the navigation bar, contained inside the wizard, can be specified through the navBarLocation input value.
This value can be either top, bottom, left or right, where the values specify the position at which the navigation bar will be shown.
In addition top and bottom will lead to a horizontal navigation bar, when left and right lead to a vertical navigation bar at the
left or right side.
If no navBarLocation is given the navigation bar will be shown at the top of the wizard.
[navBarLayout]
Another option that can be changed is the design or layout of the navigation bar.
Currently five different navigation bar layouts exist.
These are small, large-filled, large-empty, large-filled-symbols and large-empty-symbols.
The first three layouts are showing circles with or without a background, for each step of your wizard, in the navigation bar.
The second two layouts large-filled-symbols and large-empty-symbols optionally add a symbol in the center of the circle,
for each step of your wizard, in the navigation bar, if such a symbol has been defined for the step.
[navBarDirection]
Normally the steps in the navigation bar are layed out from left to right or from top to bottom.
In some cases, like with languages that are written from right to left, it may be required to change this direction to layout the steps from right to left.
To layout the steps from right to left you can pass right-to-left to the navBarDirection input of the wizard component.
[defaultStepIndex]
Per default the wizard always starts with the first wizard step, after initialisation. The same applies for a reset, where the wizard normally resets to the first step.
Sometimes this needs to be changed. If another default wizard step needs to be used, you can set it, by using the [defaultStepIndex] input of the wizard component.
For example, to start the wizard in the second step, [defaultStepIndex]="2" needs to be set.
Please be aware, that angular will interpret the given input value as a string if it's not enclosed by []!
[disableNavigationBar]
Sometimes it may be necessary to disable navigation via the navigation bar.
In such a case you can disable navigation via the navigation bar by setting the input [disableNavigationBar] of the wizard component to true.
After disabling the navigation bar, the user can't use the navigation bar anymore to navigate between steps.
Disabling the navigation bar doesn't restrict the use of elements (buttons or links) with an awNextStep, awPreviousStep or awGoToStep directive.
Parameter overview
Possible <aw-wizard> parameters:
| Parameter name |
Possible Values |
Default Value |
[navBarLocation] |
'top' | 'bottom' | 'left' | 'right' |
'top' |
[navBarLayout] |
'small' | 'large-filled' | 'large-empty' | 'large-filled-symbols' | 'large-empty-symbols' |
'small' |
[navBarDirection] |
'left-to-right' | 'right-to-left' |
'left-to-right' |
[defaultStepIndex] |
number |
0 |
[disableNavigationBar] |
boolean |
false |
<aw-wizard-step>
angular-archwizard contains two ways to define a wizard step.
One of these two ways is by using the <aw-wizard-step> component.
[stepId]
A wizard step can have its own unique id.
This id can then be used to navigate to the step.
In addition the [stepId] of a wizard step is used as the id of the li element for the wizard step in the navigation bar.
[stepTitle]
A wizard step needs to contain a title, which is shown in the navigation bar of the wizard.
To set the title of a step, add the stepTitle input attribute, with the choosen step title, to the definition of your wizard step.
[navigationSymbol]
Sometimes it's useful to add a symbol in the center of the circle in the navigation bar, which belongs to the step.
angular-archwizard supports this through the [navigationSymbol] input attribute of the wizard step.
Be aware, that not all layouts display the symbols.
Only the layouts large-filled-symbols and large-empty-symbols display the symbols!
If you want to add a 2 to the circle in the navigation bar belonging to the second step, you can do it like this:
<aw-wizard-step stepTitle="Second Step" [navigationSymbol]="{ symbol: '2' }">
...
</aw-wizard-step>
In addition to normal symbols it's also possible to use an icon from a font as a symbol.
To use an icon from a font you need to first search for the unicode belonging to the icon you want to insert.
Afterwards you can use the unicode in the numeric character reference
format as the symbol for the step.
In addition you need to specify the font family, to which the icon belongs, otherwise the symbol can't be displayed correctly.
The font family of the used symbol can be specified via the fontFamily field of the given [navigationSymbol] json input object.
For example, if you want to show the icon with the unicode \f2dd of FontAwesome inside a step circle in the navigation bar, then
you can do this via the following [navigationSymbol] input attribute:
<aw-wizard-step stepTitle="Second Step" [navigationSymbol]="{ symbol: '', fontFamily: 'FontAwesome' }">
...
</aw-wizard-step>
[canEnter]
Sometimes it's required to only allow the user to enter a specific step if a certain validation method returns true.
In such a case you can use the [canEnter] input of the targeted wizard step.
This input can be either a boolean, which directly tells the wizard if the targeted step can be entered,
or a lambda function, taking a MovingDirection and returning a boolean or a Promise<boolean>.
This function will then be called, with the direction in which the targeted step will be entered, whenever an operation has been performed, that leads to a change of the current step.
It then returns true, when the step change should succeed and false otherwise.
[canExit]
If you have an additional check or validation you need to perform to decide, if the step can be exited (both to the next step and to the previous step),
you can either pass a boolean or a function, taking a MovingDirection enum and returning a boolean or a Promise<boolean>, to the [canExit] attribute of the wizard step.
This boolean, or function, is taken into account, when an operation has been performed, which leads to a transition of the current step.
If [canExit] has been bound to a boolean, it needs to be true to leave the step in either direction (foreward AND backward).
If only exiting in one direction should be covered, you can pass a function, taking a MovingDirection and returning a boolean, to [canExit].
This function will then be called whenever an operation has been performed, that leads to a change of the current step.
(stepEnter)
If you need to call a function to do some initialisation work before entering a wizard step you can add a stepEnter attribute to the wizard step environment like this:
<aw-wizard-step stepTitle="Second Step" (stepEnter)="enterSecondStep($event)">
...
</aw-wizard-step>
This leads to the calling of the enterSecondStep function when the wizard moves to this step.
When the first step of the wizard contains a stepEnter function, it not only gets called
when the user moves back from a later step to the first step, but also after the wizard is initialized.
The event emitter will call the given function with a parameter that contains the MovingDirection of the user.
If the user went backwards, for example from the third step to the second or first step, then MovingDirection.Backwards will be passed to the function.
If the user went forwards MovingDirection.Forwards will be passed to the function.
(stepExit)
Similar to stepEnter you can add a stepExit attribute to the wizard step environment, if you want to call a function every time a wizard step is exited
either by pressing on a component with an awNextStep or awPreviousStep directive, or by a click on the navigation bar.
stepExit, like stepEnter can call the given function with an argument of type MovingDirection that signalises in which direction the step was exited.
Parameter overview
Possible <aw-wizard-step> parameters:
| Parameter name |
Possible Values |
Default Value |
[stepId] |
string |
null |
[stepTitle] |
string |
null |
[navigationSymbol] |
{symbol: string, fontFamily?: string} |
{symbol: ''} |