MatStepper
Themat-stepper provides a wizard-like workflow by dividing content into logical steps. It supports both horizontal and vertical orientations with step navigation and validation.
Basic Usage
API Reference
MatStepper
Selector:mat-stepper, mat-horizontal-stepper, mat-vertical-stepper
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
selectedIndex | number | 0 | The index of the selected step |
linear | boolean | false | Whether the user can navigate to a step without completing the previous steps |
orientation | 'horizontal' | 'vertical' | 'horizontal' | Orientation of the stepper |
labelPosition | 'bottom' | 'end' | 'end' | Position of the label in horizontal orientation |
headerPosition | 'top' | 'bottom' | 'top' | Position of the header in horizontal orientation |
animationDuration | string | '500ms' | Duration for the animation |
disableRipple | boolean | false | Whether ripples should be disabled for the step headers |
color | ThemePalette | - | Theme color for the stepper (M2 only) |
Outputs
| Name | Type | Description |
|---|---|---|
selectionChange | EventEmitter<StepperSelectionEvent> | Event emitted when the selected step changes |
animationDone | EventEmitter<void> | Event emitted when the animation completes |
Methods
| Method | Description |
|---|---|
next(): void | Selects the next step |
previous(): void | Selects the previous step |
reset(): void | Resets the stepper to its initial state |
MatStep
Selector:mat-step
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
stepControl | AbstractControl | - | The top level abstract control of the step |
label | string | - | Plain text label of the step |
errorMessage | string | - | Error message to display when validation fails |
optional | boolean | false | Whether step is optional |
completed | boolean | - | Whether step is marked as completed |
editable | boolean | true | Whether user can return to this step once it has been marked as completed |
state | string | - | Custom state for the step |
color | ThemePalette | - | Theme color for the step (M2 only) |
MatStepLabel
Directive:[matStepLabel]
Template for step label:
MatStepContent
Directive:[matStepContent]
Template for lazy-loaded step content:
MatStepperNext
Directive:matStepperNext
Button to move to the next step.
MatStepperPrevious
Directive:matStepperPrevious
Button to move to the previous step.
Examples
Vertical Stepper
Linear Stepper
Optional Steps
Editable Steps
Custom Step Icons
Lazy Loading Steps
Responsive Stepper
Accessibility
Keyboard Interaction
LEFT_ARROW: Move to previous step (horizontal)RIGHT_ARROW: Move to next step (horizontal)UP_ARROW: Move to previous step (vertical)DOWN_ARROW: Move to next step (vertical)HOME: Move to first stepEND: Move to last stepENTERorSPACE: Activate focused step
ARIA
The stepper has proper ARIA roles and attributes. Use descriptive labels:Error Messages
Provide clear error messages for validation:Styling
Form Integration
Integrate with Angular Forms:Best Practices
- Clear labels: Use descriptive step labels
- Logical flow: Order steps in a logical sequence
- Validation: Validate each step before allowing progression
- Progress indication: Show users where they are in the process
- Navigation: Provide clear next/previous buttons
- Responsive: Consider vertical layout for mobile devices
- Error handling: Provide clear error messages