Skip to content

Commit 9662e81

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 d29df38 commit 9662e81

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

src/material/card/_card-theme.scss

+13-12
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,22 @@
2727
@mixin mat-card-typography($config) {
2828
.mat-card {
2929
font-family: mat-font-family($config);
30-
}
3130

32-
.mat-card-title {
33-
font: {
34-
size: mat-font-size($config, headline);
35-
weight: mat-font-weight($config, title);
31+
// These need the extra specificity, because they can be
32+
// easily overridden by the global typography styles.
33+
.mat-card-title {
34+
font-size: mat-font-size($config, headline);
35+
font-weight: mat-font-weight($config, headline);
36+
line-height: normal;
3637
}
37-
}
3838

39-
.mat-card-header .mat-card-title {
40-
font-size: mat-font-size($config, title);
41-
}
39+
.mat-card-header .mat-card-title {
40+
font-size: mat-font-size($config, title);
41+
}
4242

43-
.mat-card-subtitle,
44-
.mat-card-content {
45-
font-size: mat-font-size($config, body-1);
43+
.mat-card-subtitle,
44+
.mat-card-content {
45+
font-size: mat-font-size($config, body-1);
46+
}
4647
}
4748
}

src/material/card/card.scss

+11-6
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,20 @@ $mat-card-header-size: 40px !default;
4848
margin-bottom: 16px;
4949
}
5050

51-
.mat-card-title {
52-
display: block;
53-
margin-bottom: 8px;
54-
}
51+
.mat-card {
52+
// Needs slightly higher specificity due to it potentially
53+
// being overridden by the global typography styles.
54+
.mat-card-title {
55+
display: block;
56+
margin-bottom: 8px;
57+
}
5558

56-
.mat-card-subtitle, .mat-card-content {
57-
@extend %mat-card-section-base;
59+
.mat-card-subtitle, .mat-card-content {
60+
@extend %mat-card-section-base;
61+
}
5862
}
5963

64+
6065
.mat-card-actions {
6166
@extend %mat-card-section-base;
6267
margin-left: -$mat-card-padding / 2;

0 commit comments

Comments
 (0)