API for stepper

API reference for Angular Material stepper

import {MatStepperModule} from '@angular/material/stepper';

Stepper data that is required for internationalization.

Properties
Name Description

changes: Subject<void>

Stream that emits whenever the labels here are changed. Use this to notify components if the labels have changed after initialization.

completedLabel: string

Label that is used to indicate step as completed to screen readers.

editableLabel: string

Label that is used to indicate step as editable to screen readers.

optionalLabel: string

Label that is rendered below optional steps.

Selector: [matStepLabel]

Properties
Name Description

template: inject<TemplateRef<any>>(TemplateRef)

Selector: mat-step

Exported as: matStep
Properties
Name Description
@Input('aria-label')

ariaLabel: string

Aria label for the tab.

@Input('aria-labelledby')

ariaLabelledby: string

Reference to the element that the tab is labelled by. Will be cleared if aria-label is set at the same time.

@Input()

color: ThemePalette

Theme color for the particular step. This API is supported in M2 themes only, it has no effect in M3 themes. For color customization in M3, see https://material.angular.io/components/stepper/styling.

For information on applying color variants in M3, see https://material.angular.io/guide/material-2-theming#optional-add-backwards-compatibility-styles-for-color-variants

@Input({ transform: booleanAttribute })

completed: boolean

Whether step is marked as completed.

@Input({ transform: booleanAttribute })

editable: boolean

Whether the user can return to this step once it has been marked as completed.

@Input()

errorMessage: string

Error message to display when there's an error.

@Input({ transform: booleanAttribute })

hasError: boolean

Whether step has an error.

@Input()

label: string

Plain text label of the step.

@Input({ transform: booleanAttribute })

optional: boolean

Whether the completion of step is optional.

@Input()

state: StepState

State of the step.

@Input()

stepControl: AbstractControl

The top level abstract control of the step.

@Output('interacted')

interactedStream: EventEmitter<CdkStep>

Emits when the user has attempted to move away from the step.

content: TemplateRef<any>

Template for step content.

interacted: false

Whether user has attempted to move away from the step.

stepLabel: MatStepLabel

Content for step label given by <ng-template matStepLabel>.

Methods
isErrorState

Custom error state matcher that additionally checks for validity of interacted form.

Parameters

control

AbstractControl<any, any>

form

FormGroupDirective | NgForm

Returns
boolean

reset

Resets the step to its initial state. Note that this includes resetting form data.

select

Selects this step component.

Selector: mat-stepper mat-vertical-stepper mat-horizontal-stepper [matStepper]

Exported as: matStepper, matVerticalStepper, matHorizontalStepper
Properties
Name Description
@Input()

animationDuration: string

Duration for the animation. Will be normalized to milliseconds if no units are set.

@Input()

color: ThemePalette

Theme color for all of the steps in stepper. This API is supported in M2 themes only, it has no effect in M3 themes. For color customization in M3, see https://material.angular.io/components/stepper/styling.

For information on applying color variants in M3, see https://material.angular.io/guide/material-2-theming#optional-add-backwards-compatibility-styles-for-color-variants

@Input()

disableRipple: boolean

Whether ripples should be disabled for the step headers.

@Input()

headerPosition: 'top' | 'bottom'

Position of the stepper's header. Only applies in the horizontal orientation.

@Input()

labelPosition: 'bottom' | 'end'

Whether the label should display in bottom or end position. Only applies in the horizontal orientation.

@Input({ transform: booleanAttribute })

linear: boolean

Whether the validity of previous steps should be checked or not.

@Input()

orientation: StepperOrientation

Orientation of the stepper.

@Input()

selected: CdkStep | undefined

The step that is selected.

@Input({ transform: numberAttribute })

selectedIndex: number

The index of the selected step.

@Output()

animationDone: EventEmitter<void>

Event emitted when the current step is done transitioning in.

@Output()

selectedIndexChange: EventEmitter<number>

Output to support two-way binding on [(selectedIndex)]

@Output()

selectionChange: EventEmitter<StepperSelectionEvent>

Event emitted when the selected step has changed.

steps: QueryList<MatStep>

Steps that belong to the current stepper, excluding ones from nested steppers.

Methods
next

Selects and focuses the next step in list.

previous

Selects and focuses the previous step in list.

reset

Resets the stepper to its initial state. Note that this includes clearing form data.

Button that moves to the next step in a stepper workflow.

Selector: button[matStepperNext]

Properties
Name Description
@Input()

type: string

Type of the next button. Defaults to "submit" if not specified.

Button that moves to the previous step in a stepper workflow.

Selector: button[matStepperPrevious]

Properties
Name Description
@Input()

type: string

Type of the previous button. Defaults to "button" if not specified.

Selector: mat-step-header

Properties
Name Description
@Input()

active: boolean

Whether the given step label is active.

@Input()

color: ThemePalette

Theme color of the step header. This API is supported in M2 themes only, it has no effect in M3 themes. For color customization in M3, see https://material.angular.io/components/stepper/styling.

For information on applying color variants in M3, see https://material.angular.io/guide/material-2-theming#optional-add-backwards-compatibility-styles-for-color-variants

@Input()

disableRipple: boolean

Whether the ripple should be disabled.

@Input()

errorMessage: string

Error message to display when there's an error.

@Input()

iconOverrides: { [key: string]: TemplateRef<MatStepperIconContext>; }

Overrides for the header icons, passed in via the stepper.

@Input()

index: number

Index of the given step.

@Input()

label: MatStepLabel | string

Label of the given step.

@Input()

optional: boolean

Whether the given step is optional.

@Input()

selected: boolean

Whether the given step is selected.

@Input()

state: StepState

State of the given step.

Methods
focus

Focuses the step header.

Parameters

origin?

FocusOrigin

options?

FocusOptions

Template to be used to override the icons inside the step header.

Selector: ng-template[matStepperIcon]

Properties
Name Description
@Input('matStepperIcon')

name: StepState

Name of the icon to be overridden.

templateRef: inject<TemplateRef<MatStepperIconContext>>(TemplateRef)

Content for a mat-step that will be rendered lazily.

Selector: ng-template[matStepContent]

Template context available to an attached matStepperIcon.

Properties
Name Description

active: boolean

Whether the step is currently active.

index: number

Index of the step.

optional: boolean

Whether the step is optional.

API reference for Angular Material stepper-testing

import {MatStepperHarness} from '@angular/material/stepper/testing';

Harness for interacting with a standard Material stepper in tests.

Properties
Name Description

static hostSelector: '.mat-stepper-horizontal, .mat-stepper-vertical'

The selector for the host element of a MatStepper instance.

Methods
async
getOrientation

Gets the orientation of the stepper.

Returns
Promise<StepperOrientation>

async
getSteps

Gets the list of steps in the stepper.

Parameters

filter

StepHarnessFilters = {}

Optionally filters which steps are included.

Returns
Promise<MatStepHarness[]>

async
host

Gets a Promise for the TestElement representing the host element of the component.

Returns
Promise<TestElement>

async
selectStep

Selects a step in this stepper.

Parameters

filter

StepHarnessFilters = {}

An optional filter to apply to the child steps. The first step matching the filter will be selected.

Returns
Promise<void>

Promise that resolves when the action completes.

static
with

Gets a HarnessPredicate that can be used to search for a MatStepperHarness that meets certain criteria.

Parameters

options

StepperHarnessFilters = {}

Options for filtering which stepper instances are considered a match.

Returns
HarnessPredicate<MatStepperHarness>

a HarnessPredicate configured with the given options.

Harness for interacting with a standard Angular Material step in tests.

Properties
Name Description

static hostSelector: '.mat-step-header'

The selector for the host element of a MatStep instance.

Methods
async
getAllChildLoaders
Parameters

selector

S

Returns
Promise<HarnessLoader[]>

async
getAllHarnesses
Parameters

query

HarnessQuery<T>

Returns
Promise<T[]>

async
getAriaLabel

Gets the aria-label of the step.

Returns
Promise<string | null>

async
getAriaLabelledby

Gets the value of the aria-labelledby attribute.

Returns
Promise<string | null>

async
getChildLoader
Parameters

selector

S

Returns
Promise<HarnessLoader>

async
getHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<T>

async
getHarnessOrNull
Parameters

query

HarnessQuery<T>

Returns
Promise<T | null>

async
getLabel

Gets the label of the step.

Returns
Promise<string>

async
getRootHarnessLoader
Returns
Promise<HarnessLoader>

async
hasErrors

Whether the step is currently showing its error state. Note that this doesn't mean that there are or aren't any invalid form controls inside the step, but that the step is showing its error-specific styling which depends on there being invalid controls, as well as the ErrorStateMatcher determining that an error should be shown and that the showErrors option was enabled through the STEPPER_GLOBAL_OPTIONS injection token.

Returns
Promise<boolean>

async
hasHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<boolean>

async
host

Gets a Promise for the TestElement representing the host element of the component.

Returns
Promise<TestElement>

async
isCompleted

Whether the step has been filled out.

Returns
Promise<boolean>

async
isOptional

Whether the step is optional.

Returns
Promise<boolean>

async
isSelected

Whether the step is selected.

Returns
Promise<boolean>

async
select

Selects the given step by clicking on the label. The step may not be selected if the stepper doesn't allow it (e.g. if there are validation errors).

Returns
Promise<void>

Promise that resolves when the action completes.

static
with

Gets a HarnessPredicate that can be used to search for a MatStepHarness that meets certain criteria.

Parameters

options

StepHarnessFilters = {}

Options for filtering which steps are considered a match.

Returns
HarnessPredicate<MatStepHarness>

a HarnessPredicate configured with the given options.

Harness for interacting with a standard Angular Material stepper next button in tests.

Properties
Name Description

static hostSelector: '.mat-stepper-next'

The selector for the host element of a MatStep instance.

Methods
click

Clicks the button.

Returns
Promise<void>

getText

Gets the text of the button.

Returns
Promise<string>

async
host

Gets a Promise for the TestElement representing the host element of the component.

Returns
Promise<TestElement>

static
with

Gets a HarnessPredicate that can be used to search for a MatStepperNextHarness that meets certain criteria.

Parameters

options

StepperButtonHarnessFilters = {}

Options for filtering which steps are considered a match.

Returns
HarnessPredicate<MatStepperNextHarness>

a HarnessPredicate configured with the given options.

Harness for interacting with a standard Angular Material stepper previous button in tests.

Properties
Name Description

static hostSelector: '.mat-stepper-previous'

The selector for the host element of a MatStep instance.

Methods
click

Clicks the button.

Returns
Promise<void>

getText

Gets the text of the button.

Returns
Promise<string>

async
host

Gets a Promise for the TestElement representing the host element of the component.

Returns
Promise<TestElement>

static
with

Gets a HarnessPredicate that can be used to search for a MatStepperPreviousHarness that meets certain criteria.

Parameters

options

StepperButtonHarnessFilters = {}

Options for filtering which steps are considered a match.

Returns
HarnessPredicate<MatStepperPreviousHarness>

a HarnessPredicate configured with the given options.

A set of criteria that can be used to filter a list of MatStepHarness instances.

Properties
Name Description

completed: boolean

Only find completed steps.

invalid: boolean

Only find steps that have errors.

label: string | RegExp

Only find instances whose label matches the given value.

selected: boolean

Only find steps with the given selected state.

A set of criteria that can be used to filter a list of MatStepperHarness instances.

Properties
Name Description

orientation: StepperOrientation

Only find instances whose orientation matches the given value.

A set of criteria that can be used to filter a list of MatStepperNextHarness and MatStepperPreviousHarness instances.

Properties
Name Description

text: string | RegExp

Only find instances whose text matches the given value.