Skip to content

Commit 2b9d944

Browse files
committed
fix(card): title styles being overridden by global typography
Fixes the card title styles potentially being overridden by the global `.mat-typography` styles if the title is set on a header node. Fixes #10215.
1 parent 67e710c commit 2b9d944

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

src/lib/card/_card-theme.scss

+11-10
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,19 @@
2020
@mixin mat-card-typography($config) {
2121
.mat-card {
2222
font-family: mat-font-family($config);
23-
}
2423

25-
.mat-card-title {
26-
font: {
27-
size: mat-font-size($config, headline);
28-
weight: mat-font-weight($config, headline);
24+
// These need the extra specificity, because they can be
25+
// easily overridden by the global typography styles.
26+
.mat-card-title {
27+
font-size: mat-font-size($config, headline);
28+
font-weight: mat-font-weight($config, headline);
29+
line-height: normal;
2930
}
30-
}
3131

32-
.mat-card-subtitle,
33-
.mat-card-content,
34-
.mat-card-header .mat-card-title {
35-
font-size: mat-font-size($config, body-1);
32+
.mat-card-subtitle,
33+
.mat-card-content,
34+
.mat-card-header .mat-card-title {
35+
font-size: mat-font-size($config, body-1);
36+
}
3637
}
3738
}

src/lib/card/card.scss

+6-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@ $mat-card-header-size: 40px !default;
4747
margin-bottom: 16px;
4848
}
4949

50-
.mat-card-title, .mat-card-subtitle, .mat-card-content {
51-
@extend %mat-card-section-base;
50+
// Needs slightly higher specificity due to it potentially
51+
// being overridden by the global typography styles.
52+
.mat-card {
53+
.mat-card-title, .mat-card-subtitle, .mat-card-content {
54+
@extend %mat-card-section-base;
55+
}
5256
}
5357

5458
.mat-card-actions {

0 commit comments

Comments
 (0)