Success Criterion 1.4.3 - Level AA
Contrast (Minimum)
Ensure that the contrast ratio between the text colour and background colour is at least 4.5:1. For bold and large text, a ratio of 3:1 is sufficient. By maintaining these ratios, visually impaired and colour blind users can usually read the text well. In addition, this makes an app easier for everyone to use, for example outside in the sun.
Impact
If text has too little contrast, visually impaired people cannot read it well.
Sufficient contrast makes an app easier for everyone to use. For example, outside in the sun.
Check
"Is the contrast of normal text at least 4.5:1 and the contrast of bold or large text at least 3:1?"
You can take a screenshot of an app to determine the colour codes and calculate the contrast. This can be done, for example, with the Contrast Checker of WebAIM.
Solution
Calculate contrast
On Android, you can use the Accessibility Scanner app to detect contrast issues automatically.
Support dark mode
On Android, you can detect dark mode by checking if the uiMode
configuration contains UI_MODE_NIGHT_MASK
.
By adding -night
resources to your project you can let Android automatically pick the right resources. For example, add a colors.xml
file inside a values-night
folder to specify night mode colors.
fun Context.isInNightMode(): Boolean {
val nightModeFlags = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
return nightModeFlags == Configuration.UI_MODE_NIGHT_YES
}