angular / angular/components

bug(mat-toolbar): mat-toolbar styles for elements like h1, h2, ... are not taking precedence over mat-typography

Open
#26,261 2 comments 4 reactions 0 assignees View on GitHub
area: material/toolbar good first issue 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

When a header tag is used within mat-toolbar the stylings from the theme do not take precedence.
The default styles from mat-typography are still used. Therefore the margin is not reset to 0 and the font-size also differs.

![image](https://user-images.githubusercontent.com/5477981/207587289-b7ba6a95-9ae1-49f6-bfc7-3585a74cd285.png)

### Reproduction

https://stackblitz.com/edit/components-issue-t1dkvg

Steps to reproduce:
1. Apply mat-typography class to body
2. Add h1 tag with text to mat-toolbar

### Expected Behavior

Specific styles from mat-toolbar for these elements should take precedence. e.g. margin should be 0.

### Actual Behavior

Default mat-typography styles are used even though mat-toolbar would specify more accurate ones.

### Environment

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

Contributor guide

Open the contributing guide

Research direction

Start with the linked StackBlitz reproduction and compare the styles applied by mat-toolbar with those from the mat-typography class on the body. Trace the toolbar typography styles for h1, h2, and similar elements; done means their intended toolbar styles take precedence, including a zero margin and the expected font size.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.