Skip to content

Commit b081b09

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 4b15b78 commit b081b09

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

src/lib/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/lib/card/card.scss

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

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

54-
.mat-card-subtitle, .mat-card-content {
55-
@extend %mat-card-section-base;
57+
.mat-card-subtitle, .mat-card-content {
58+
@extend %mat-card-section-base;
59+
}
5660
}
5761

62+
5863
.mat-card-actions {
5964
@extend %mat-card-section-base;
6065
margin-left: -$mat-card-padding / 2;

0 commit comments

Comments
 (0)