angular / angular/components

bug(Typography): Default font settings on `.mat-typography` is `body-2` instead of `body-1`

Offen
#27,112 13 Kommentare 3 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: theming P5
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

14

### Description

When a theme is configured according to the docs, and typography is set up by adding this line:
`@include mat.typography-hierarchy(mat.define-typography-config())`
https://v15.material.angular.io/guide/typography#using-typography-styles-in-your-application

Applying the `.mat-typography` class on the body element defines `body-2` as the default font for the application:
https://github.com/angular/components/blob/16.0.1/src/material/core/typography/_typography.scss#L273

body-1 has a font-size of 16px.
body-2 has a font-size of 14px;

The docs say:
`body-1` | Base body text.
`body-2` | Secondary body text.
https://github.com/angular/components/blob/16.0.1/guides/typography.md?plain=1#L54

If `body-1` is considered `base body text`, I expect it to apply when using the `mat-typography` css class, and not `body-2`.

### Reproduction

1. Follow the docs to set up typography styles in a brand new Angular + Angular Material app:
https://v15.material.angular.io/guide/typography#using-typography-styles-in-your-application

2. Add `mat-typography` to the `body` tag.

3. Inspect font-size on the `body` tag.

### Expected Behavior

I expect `body-1` to be the default font settings which apply when using `mat-typography` (since the docs claim this is `base body text`).

### Actual Behavior

`body-2` is the default font settings when using `@include mat.typography-hierarchy(mat.define-typography-config())` instead of `body-1`.

### Environment

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne in src/material/core/typography/_typography.scss beim verlinkten Selektor und vergleiche ihn mit guides/typography.md und der Dokumentation zur Typografie. Befolge die Reproduktionsschritte in einer neuen Angular Material-App; abgeschlossen ist die Aufgabe, wenn `.mat-typography` die dokumentierten grundlegenden Einstellungen für den Fließtext anwendet statt der sekundären Einstellungen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular
Bereich
frontend
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

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