Skip to content

Commit 05ba139

Browse files
committed
fix(button): font color incorrect for buttons with background
Right now, the font-color for buttons with a background color (raised, fab, mini-fab) with the default `color` palette is not set properly. This is because the `currentColor` CSS property overwrites the font color from the theme for those buttons. To fix the issue, the `currentColor` can be only used on buttons without a background color (normal and icon-buttons). While being at it, using `inherited` as value is more readable and results in the same behavior. Fixes #4614.
1 parent 4523556 commit 05ba139

File tree

3 files changed

+37
-12
lines changed

3 files changed

+37
-12
lines changed

src/demo-app/toolbar/toolbar-demo.html

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,58 @@
11
<div class="demo-toolbar">
2-
32
<p>
43
<mat-toolbar>
5-
<mat-icon class="demo-toolbar-icon">menu</mat-icon>
6-
<span>Default Toolbar</span>
4+
<button mat-icon-button>
5+
<mat-icon>menu</mat-icon>
6+
</button>
77

8+
<span>Default Toolbar</span>
89
<span class="demo-fill-remaining"></span>
910

10-
<mat-icon>code</mat-icon>
11+
<button mat-icon-button>
12+
<mat-icon>code</mat-icon>
13+
</button>
14+
15+
<button mat-icon-button color="warn">
16+
<mat-icon>code</mat-icon>
17+
</button>
1118
</mat-toolbar>
1219
</p>
1320

1421
<p>
1522
<mat-toolbar color="primary">
16-
<mat-icon class="demo-toolbar-icon">menu</mat-icon>
17-
<span>Primary Toolbar</span>
23+
<button mat-icon-button>
24+
<mat-icon>menu</mat-icon>
25+
</button>
1826

27+
<span>Primary Toolbar</span>
1928
<span class="demo-fill-remaining"></span>
2029

21-
<mat-icon>code</mat-icon>
30+
<button mat-raised-button>Text</button>
31+
<button mat-raised-button color="accent">Accent</button>
2232
</mat-toolbar>
2333
</p>
2434

2535
<p>
2636
<mat-toolbar color="accent">
27-
<mat-icon class="demo-toolbar-icon">menu</mat-icon>
28-
<span>Accent Toolbar</span>
37+
<button mat-icon-button>
38+
<mat-icon>menu</mat-icon>
39+
</button>
2940

41+
<span>Accent Toolbar</span>
3042
<span class="demo-fill-remaining"></span>
3143

32-
<mat-icon>code</mat-icon>
44+
<button mat-raised-button>Text</button>
45+
<button mat-mini-fab color="">
46+
<mat-icon>done</mat-icon>
47+
</button>
48+
<button mat-mini-fab color="primary">
49+
<mat-icon>done</mat-icon>
50+
</button>
3351
</mat-toolbar>
3452
</p>
3553

3654
<p>
37-
<mat-toolbar color="accent">
55+
<mat-toolbar>
3856
<mat-toolbar-row>First Row</mat-toolbar-row>
3957
<mat-toolbar-row>Second Row</mat-toolbar-row>
4058
</mat-toolbar>

src/demo-app/toolbar/toolbar-demo.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@
99
flex: 1 1 auto;
1010
}
1111

12+
button {
13+
margin: 0 4px;
14+
}
1215
}

src/lib/button/button.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,16 @@
5252

5353
// The text and icon should be vertical aligned inside a button
5454
.mat-button, .mat-raised-button, .mat-icon-button, .mat-fab, .mat-mini-fab {
55-
color: currentColor;
5655
.mat-button-wrapper > * {
5756
vertical-align: middle;
5857
}
5958
}
6059

60+
// Buttons that don't have a background color can inherit the color from its parent.
61+
.mat-button, .mat-icon-button {
62+
color: inherit;
63+
}
64+
6165
// The ripple container should match the bounds of the entire button.
6266
.mat-button-ripple, .mat-button-focus-overlay {
6367
@include mat-fill;

0 commit comments

Comments
 (0)