Skip to content

Commit 205a2f5

Browse files
crisbetoannieyw
authored andcommitted
fix(material/checkbox): add more prominent focus indication in high contrast mode
Currently the checkbox only switches to a dotted border when it receives focus in high contrast mode. These changes make it a bit more prominent by using a solid outline on the ripple element.
1 parent 23a0248 commit 205a2f5

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

src/material/checkbox/checkbox.scss

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,24 @@ $_mat-checkbox-mark-stroke-size: 2 / 15 * checkbox-common.$size !default;
193193
.mat-ripple-element:not(.mat-checkbox-persistent-ripple) {
194194
opacity: 0.16;
195195
}
196+
197+
// Increase specificity because ripple styles are part of the `mat-core` mixin and can
198+
// potentially overwrite the absolute position of the container.
199+
.mat-checkbox-ripple {
200+
position: absolute;
201+
left: calc(50% - #{$_mat-checkbox-ripple-radius});
202+
top: calc(50% - #{$_mat-checkbox-ripple-radius});
203+
height: $_mat-checkbox-ripple-radius * 2;
204+
width: $_mat-checkbox-ripple-radius * 2;
205+
z-index: 1;
206+
pointer-events: none;
207+
}
208+
209+
&.cdk-keyboard-focused .mat-checkbox-ripple {
210+
@include a11y.high-contrast(active, off) {
211+
outline: solid 3px;
212+
}
213+
}
196214
}
197215

198216
.mat-checkbox-layout {
@@ -258,14 +276,6 @@ $_mat-checkbox-mark-stroke-size: 2 / 15 * checkbox-common.$size !default;
258276
._mat-animation-noopable & {
259277
transition: none;
260278
}
261-
262-
.mat-checkbox.cdk-keyboard-focused & {
263-
@include a11y.high-contrast(active, off) {
264-
// Note that we change the border style of the checkbox frame to dotted because this
265-
// is how IE/Edge similarly treats native checkboxes in high contrast mode.
266-
border-style: dotted;
267-
}
268-
}
269279
}
270280

271281
.mat-checkbox-background {
@@ -506,15 +516,3 @@ $_mat-checkbox-mark-stroke-size: 2 / 15 * checkbox-common.$size !default;
506516
bottom: 0;
507517
left: 50%;
508518
}
509-
510-
// Increase specificity because ripple styles are part of the `mat-core` mixin and can
511-
// potentially overwrite the absolute position of the container.
512-
.mat-checkbox .mat-checkbox-ripple {
513-
position: absolute;
514-
left: calc(50% - #{$_mat-checkbox-ripple-radius});
515-
top: calc(50% - #{$_mat-checkbox-ripple-radius});
516-
height: $_mat-checkbox-ripple-radius * 2;
517-
width: $_mat-checkbox-ripple-radius * 2;
518-
z-index: 1;
519-
pointer-events: none;
520-
}

0 commit comments

Comments
 (0)