I'm looking for a simple way to detect if the user's system is in high contrast mode or not using javascript/typescript within a react app.
Is there a public method available in a library somewhere?
These stackoverflow posts don't give me what I'm looking for, which is a method from an import:
Detect if 'High contrast' is enabled in Android accessibility settings
How to detect MAC OS inverted color mode in JavaScript / CSS?
How do I detect if a user has Mac OS high contrast accessibility settings enabled?
EDIT: I intend to be able to differentiate between black on white and white on black mode
EDIT: Here is what I've tried but it doesn't get applied in Chrome
/* Targets displays using the Windows’ "High Contrast Black" theme: */
@media screen and (-ms-high-contrast: white-on-black) {
.targetClass {
color: white;
background-color: black;
}
}
/* Targets displays using the Windows’ "High Contrast White" theme: */
@media screen and (-ms-high-contrast: black-on-white) {
.targetClass {
color: black;
background-color: white;
}
}