dequelabs / dequelabs/axe-core

color-contrast support for basic gradient backgrounds

Open
#4,628 0 comments 0 reactions 0 assignees View on GitHub
color contrast feat
Dominant language
JavaScript
Stars
7.5k
Forks
933
Avg merge
2d 23h
Merged PRs (30d)
17

Description

### Product

axe-core

### Feature Description

Today, `color-contrast` gives an `incomplete` result anytime it detects text with a `background-image` that involves any sort of `gradient`.

However, it's relatively common for gradient backgrounds to be "simple" cases like this:

```html

Text

```

...where color contrast would pass if tested at any point along the interpolation between the 2 color stops.

It would be a nice feature for axe-core to be able to handle "simple" gradient cases like this by testing a foreground color against *multiple* background colors and only giving a `bgGradient` incomplete if the different tests give different results.

In color spaces where relative luminance changes monotonically during a gradient interpolation (eg, sRGB), this would just require testing against each color stop (and confirming that "which of fg and bg is lighter" doesn't swap between the stops). In other color spaces (probably including the default gradient interpolation color space (oklab)), it might be simplest to just pick some arbitrary number of points in the color space along the interpolation and test each.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.