Skip to content

Commit ba3ec6c

Browse files
crisbetoandrewseguin
authored andcommitted
fix(material-experimental/chips): high contrast mode fixes (#16811)
Fixes the following issues with the MDC-based chips in high contrast mode: * Chips blending in with the background because they don't have an outline or a border. * No focus indication being visible. * Chips being hidden completely on hover because we were using an RGBA overlay.
1 parent 6a21d94 commit ba3ec6c

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/material-experimental/mdc-chips/chips.scss

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@import '@material/chips/mixins';
22
@import '../../material/core/style/noop-animation';
3+
@import '../../cdk/a11y/a11y';
34
@import '../mdc-helpers/mdc-helpers';
45

56
@include mdc-chip-without-ripple($query: $mat-base-styles-query);
@@ -13,6 +14,15 @@
1314
overflow: hidden;
1415
// Required for the ripple to clip properly in Safari.
1516
transform: translateZ(0);
17+
18+
@include cdk-high-contrast {
19+
outline: solid 1px;
20+
21+
&:focus {
22+
// Use 2px here since the dotted outline is a little thinner.
23+
outline: dotted 2px;
24+
}
25+
}
1626
}
1727

1828
// The MDC chip styles related to hover and focus states are intertwined with the MDC ripple styles.
@@ -25,9 +35,13 @@
2535
position: absolute;
2636
width: 100%;
2737
height: 100%;
28-
background: rgba(0, 0, 0, 0.2);
38+
39+
// Note that we use a `background` and `opacity`, instead of an `rgba` background, because
40+
// `rgba` backgrounds get converted into solid colors in high contrast mode.
41+
background: #000;
42+
opacity: 0.2;
2943
top: 0;
30-
left:0;
44+
left: 0;
3145
pointer-events: none;
3246
}
3347
}

0 commit comments

Comments
 (0)