Skip to content

Commit ff9059d

Browse files
authored
fix(material/checkbox): use GrayText for disabled colors in high contrast mode (#32066)
Uses `GrayText` for the color of the checkbox in high contrast mode, instead of reducing the opacity which can also make the checkbox harder to see.
1 parent 544438c commit ff9059d

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

src/material/checkbox/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ sass_binary(
6767
deps = [
6868
":checkbox_common",
6969
":m2",
70+
"//src/cdk:sass_lib",
7071
"//src/material/core/style:layout_common",
7172
"//src/material/core/tokens:token_utils",
7273
],

src/material/checkbox/_checkbox-common.scss

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ $_fallback-size: 40px;
6363
.mdc-checkbox--disabled {
6464
cursor: default;
6565
pointer-events: none;
66-
67-
@include cdk.high-contrast {
68-
opacity: 0.5;
69-
}
7066
}
7167

7268
.mdc-checkbox__background {
@@ -107,12 +103,20 @@ $_fallback-size: 40px;
107103

108104
.mdc-checkbox--disabled .mdc-checkbox__background {
109105
border-color: token-utils.slot(checkbox-disabled-unselected-icon-color, $fallbacks);
106+
107+
@include cdk.high-contrast {
108+
border-color: GrayText;
109+
}
110110
}
111111

112112
.mdc-checkbox__native-control:disabled:checked ~ .mdc-checkbox__background,
113113
.mdc-checkbox__native-control:disabled:indeterminate ~ .mdc-checkbox__background {
114114
background-color: token-utils.slot(checkbox-disabled-selected-icon-color, $fallbacks);
115115
border-color: transparent;
116+
117+
@include cdk.high-contrast {
118+
border-color: GrayText;
119+
}
116120
}
117121

118122
// stylelint-disable selector-combinator-space-before
@@ -149,6 +153,10 @@ $_fallback-size: 40px;
149153
.mdc-checkbox .mdc-checkbox__native-control:focus ~ .mdc-checkbox__background,
150154
.mdc-checkbox__background {
151155
border-color: token-utils.slot(checkbox-disabled-unselected-icon-color, $fallbacks);
156+
157+
@include cdk.high-contrast {
158+
border-color: GrayText;
159+
}
152160
}
153161

154162
.mdc-checkbox__native-control:checked ~ .mdc-checkbox__background,
@@ -183,7 +191,7 @@ $_fallback-size: 40px;
183191
color: token-utils.slot(checkbox-disabled-selected-checkmark-color, $fallbacks);
184192

185193
@include cdk.high-contrast {
186-
color: CanvasText;
194+
color: GrayText;
187195
}
188196
}
189197
}
@@ -220,6 +228,10 @@ $_fallback-size: 40px;
220228
&, &.mat-mdc-checkbox-disabled-interactive {
221229
.mdc-checkbox__mixedmark {
222230
border-color: token-utils.slot(checkbox-disabled-selected-checkmark-color, $fallbacks);
231+
232+
@include cdk.high-contrast {
233+
border-color: GrayText;
234+
}
223235
}
224236
}
225237
}

src/material/checkbox/checkbox.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use '@angular/cdk';
12
@use '../core/style/layout-common';
23
@use './m3-checkbox';
34
@use '../core/tokens/token-utils';
@@ -44,6 +45,10 @@ $fallbacks: m3-checkbox.get-tokens();
4445
label {
4546
cursor: default;
4647
color: token-utils.slot(checkbox-disabled-label-color, $fallbacks);
48+
49+
@include cdk.high-contrast {
50+
color: GrayText;
51+
}
4752
}
4853
}
4954

0 commit comments

Comments
 (0)