Skip to content

Commit 55e566c

Browse files
committed
fix(material/icon): style icons properly when within a MDC button
1 parent 0911820 commit 55e566c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/material/icon/icon.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ export class MatIcon extends _MatIconMixinBase implements OnInit, AfterViewCheck
250250
// Update font classes because ngOnChanges won't be called if none of the inputs are present,
251251
// e.g. <mat-icon>arrow</mat-icon> In this case we need to add a CSS class for the default font.
252252
this._updateFontIconClasses();
253+
254+
// Add appropriate MDC class if it is inside a MDC button to be styled properly
255+
if (this._elementRef.nativeElement.parentElement?.classList.contains('mdc-button')) {
256+
this._elementRef.nativeElement.classList.add('mdc-button__icon');
257+
}
253258
}
254259

255260
ngAfterViewChecked() {

0 commit comments

Comments
 (0)