Skip to content

Commit 275ded5

Browse files
crisbetojosephperrott
authored andcommitted
fix(slide-toggle): using incorrect colors when disabled (#13444)
Based on the latest Material Design spec, disable slide toggles are supposed to retain their color, but become slightly opaque.
1 parent 076b6bf commit 275ded5

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

src/lib/slide-toggle/_slide-toggle-theme.scss

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
@import '../core/typography/typography-utils';
55

66
@mixin _mat-slide-toggle-checked($palette, $thumb-checked-hue) {
7-
// Do not apply the checked colors if the toggle is disabled, because the
8-
// specificity would be to high for the disabled styles.
9-
&.mat-checked:not(.mat-disabled) {
7+
&.mat-checked {
108
.mat-slide-toggle-thumb {
119
background-color: mat-color($palette, $thumb-checked-hue);
1210
}
@@ -39,11 +37,8 @@
3937
// specifications. See: https://material.io/design/components/selection-controls.html#specs
4038
$thumb-unchecked-hue: if($is-dark, 400, 50);
4139
$thumb-checked-hue: if($is-dark, 200, default);
42-
$thumb-disabled-hue: if($is-dark, 800, 400);
4340

4441
$bar-unchecked-color: mat-color($foreground, disabled);
45-
$bar-disabled-color: if($is-dark, rgba(white, 0.12), rgba(black, 0.1));
46-
4742
$ripple-unchecked-color: mat-color($foreground, base);
4843

4944
.mat-slide-toggle {
@@ -64,18 +59,6 @@
6459
}
6560
}
6661

67-
.mat-disabled {
68-
.mat-slide-toggle-thumb {
69-
// The thumb of the slide-toggle always uses the hue 400 of the grey palette in dark
70-
// or light themes. Since this is very specific to the slide-toggle component, we're not
71-
// providing it in the background palette.
72-
background-color: mat-color($mat-grey, $thumb-disabled-hue);
73-
}
74-
.mat-slide-toggle-bar {
75-
background-color: $bar-disabled-color;
76-
}
77-
}
78-
7962
.mat-slide-toggle-thumb {
8063
@include _mat-theme-elevation(1, $theme);
8164
background-color: mat-color($mat-grey, $thumb-unchecked-hue);

src/lib/slide-toggle/slide-toggle.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ $mat-slide-toggle-bar-track-width: $mat-slide-toggle-bar-width - $mat-slide-togg
4040
}
4141

4242
&.mat-disabled {
43+
// The value is based on MDC.
44+
opacity: 0.38;
45+
4346
.mat-slide-toggle-label, .mat-slide-toggle-thumb-container {
4447
cursor: default;
4548
}

0 commit comments

Comments
 (0)