Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions goldens/material/stepper/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ export class MatStepHeader extends CdkStepHeader implements AfterViewInit, OnDes
// (undocumented)
_getDefaultTextForState(state: StepState): string;
_getHostElement(): HTMLElement;
// (undocumented)
protected _hasEmptyLabel(): boolean;
// (undocumented)
protected _hasErrorLabel(): boolean;
// (undocumented)
protected _hasOptionalLabel(): boolean;
iconOverrides: {
[key: string]: TemplateRef<MatStepperIconContext>;
};
Expand Down
4 changes: 2 additions & 2 deletions src/material/stepper/step-header.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
<div class="mat-step-text-label">{{label}}</div>
}

@if (optional && state != 'error') {
@if (_hasOptionalLabel()) {
<div class="mat-step-optional">{{_intl.optionalLabel}}</div>
}

@if (state === 'error') {
@if (_hasErrorLabel()) {
<div class="mat-step-sub-label-error">{{errorMessage}}</div>
}
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/material/stepper/step-header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ $fallbacks: m3-stepper.get-tokens();
font-size: token-utils.slot(stepper-header-selected-state-label-text-size, $fallbacks);
font-weight: token-utils.slot(stepper-header-selected-state-label-text-weight, $fallbacks);
}

.mat-step-header-empty-label & {
min-width: 0;
}
}

.mat-step-text-label {
Expand Down
18 changes: 18 additions & 0 deletions src/material/stepper/step-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {_CdkPrivateStyleLoader, _VisuallyHiddenLoader} from '@angular/cdk/privat
styleUrl: 'step-header.css',
host: {
'class': 'mat-step-header',
'[class.mat-step-header-empty-label]': '_hasEmptyLabel()',
'[class]': '"mat-" + (color || "primary")',
'role': 'tab',
},
Expand Down Expand Up @@ -140,4 +141,21 @@ export class MatStepHeader extends CdkStepHeader implements AfterViewInit, OnDes
}
return state;
}

protected _hasEmptyLabel() {
return (
!this._stringLabel() &&
!this._templateLabel() &&
!this._hasOptionalLabel() &&
!this._hasErrorLabel()
);
}

protected _hasOptionalLabel() {
return this.optional && this.state !== 'error';
}

protected _hasErrorLabel() {
return this.state === 'error';
}
}
4 changes: 4 additions & 0 deletions src/material/stepper/stepper.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ $fallbacks: m3-stepper.get-tokens();
}
}

&.mat-step-header-empty-label .mat-step-icon {
margin: 0;
}

$vertical-padding: _get-vertical-padding-calc();

&::before,
Expand Down
Loading