angular / angular/components

bug(Theming Angular Material): Custom typography not applied to standard typography levels in mat.core-theme() or all-component-themes()

Open
#24,370 14 comments 6 reactions 0 assignees View on GitHub
area: material/core area: theming docs P3
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

### Is this a regression?

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

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

_No response_

### Description

Tried to change the font-family so that e.g. body-1 everywhere has font family Arial.
But it only changed the font-family in mat components, not outside in normal divs.

```
$my-typography: mat.define-typography-config(
$font-family: 'Arial',
);
$my-theme: mat.define-light-theme((
typography: $my-typography,
color: (
primary: $dicey-primary,
accent: $dicey-accent,
warn: $dicey-warn,
))
);
@include mat.all-component-themes($my-theme);
```

Similar problem was reported here, but not solved: https://github.com/angular/components/issues/23683#issue-1015421891

-----------------------

It works when I do it with all-component-typographies:

```
$my-typography: mat.define-typography-config(
$font-family: 'Arial',
);
@include mat.all-component-typographies($my-typography);
```

### Reproduction

Steps to reproduce:
1. Add custom theme with typography
2. See if body tag font-family changes

### Expected Behavior

Bodys font family changes to custom font family

### Actual Behavior

The body font family is standard Roboto

### Environment

- Angular: 13.1.2
- CDK/Material: 13.1.1
- Browser(s): Firefox
- Operating System (e.g. Windows, macOS, Ubuntu): Windows 11

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Angular 13.1.2 case from the issue, comparing mat.all-component-themes($my-theme) with mat.all-component-typographies($my-typography). Trace the typography mixins used by mat.core-theme() and all-component-themes(); done means the configured Arial font applies to the body and standard typography levels, not only Material components.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, sass, typescript
Domain
design, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.