angular / angular/components

bug(material/button): incorrect alignment of svg icons

Offen
#31,576 5 Kommentare 9 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: material/button P2
Vorherrschende Sprache
TypeScript
Sterne
25k
Forks
6.8k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
91

Beschreibung

### Is this a regression?

- [x] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

20.0.5

### Description

After update to angular/material 20.1.+

Material buttons with icons no longer align properly.

_________________________________________

**Before**

Image

**After**

Image

_________________________________________

**What causing an issue?**

After removing `min-height`, everything works as before.
My icon size is 24px, but with `min-height: fit-content`, the .mat-icon container gets stretched while the SVG icon remains the same size.

For example:
- `.mat-icon: 24px × 29px`
- `svg: 24px × 24px`

This causes vertical misalignment of icons compared to previous versions.

Image

I believe this PR is the cause of this issue.: https://github.com/angular/components/pull/30891
commit -> https://github.com/angular/components/pull/30891/commits/87b6962841454cfde8200b9c9de7ad73079416ae

_________________________________________

### Reproduction

StackBlitz link:
Steps to reproduce:
1.
2.

### Expected Behavior

The `.mat-icon` inside `.mat-mdc-button-base` should remain properly aligned and not stretch vertically.
The mat-icon container should match the size of the SVG icon `(24px × 24px)` when the icon size is set to `24px`.

### Actual Behavior

With `min-height: fit-content;` applied, the .mat-icon container stretches vertically `(e.g., 24px × 29px) `while the SVG icon stays 24px × 24px.
This causes misalignment and extra spacing around the icon compared to previous versions.

### Environment

- Angular: 20.1.2
- CDK/Material: 20.1.2
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): macOS

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Überprüfe die Angular Material-Button-Stile rund um `.mat-mdc-button-base` und `.mat-icon` und vergleiche anschließend das durch PR 30891 commit 87b6962841454cfde8200b9c9de7ad73079416ae eingeführte Verhalten mit Version 20.0.5. Reproduziere dies mit einem 24px-SVG-Icon in Angular/Material 20.1.2 und verifiziere, dass der Container 24px × 24px bleibt und das Icon vertikal ausgerichtet ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, css, typescript
Bereich
frontend
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.