Page MenuHomePhabricator

Evaluate color palette and its color contrast requirements with APCA
Closed, ResolvedPublic

Description

Background

While WCAG 3.0 is still under discussion and development, there is clear probability that the color contrast ratio requirements will undergo a structural update, following the Accessible Perceptual Contrast Algorithm (APCA).
The color palette is currently evaluated using WCAG 2 contrast guidelines, which may not reflect the most accurate perceptual contrast, potentially leading to less accessible color choices.

Goal

The current requirement for our design system are WCAG 2.1/2.2 level AA contrast guidelines for the colors of our palette. As WCAG 3 is under development and introduces the Advanced Perceptual Contrast Algorithm (APCA), it will be crucial to transition to APCA for more accurate and perceptually relevant color contrast assessments. However, given that WCAG 3 is not yet finalized, there are important considerations to take into account.

Rationale for Using APCA

  • Perceptual Relevance: APCA considers human vision more accurately than WCAG 2, providing better results for readability and visual comfort.
  • Advanced Metrics: APCA uses luminance contrast and spatial frequency, which are more aligned with how people perceive contrast in real-world scenarios.
  • Improved Accessibility: Using APCA can lead to better design choices that enhance readability and reduce eye strain for users with visual impairments.

Considerations and Cautions

  • Non-Finalized WCAG 3: As WCAG 3 is still under development, it is essential to stay updated with any changes or refinements to APCA. This may require regular updates to our evaluation process.
  • Backward Compatibility: Ensure that the transition to APCA does not negatively impact users who rely on WCAG 2 standards. Provide dual support or clear communication about the changes. WCAG 3 is laid out to be a breaking change which
  • This breaking change would mean that we would possibly consider not complying to then (outdated) laws
  • Implementation Complexity: Integrating APCA might require significant changes to our current evaluation logic and user interface. Proper testing and validation are necessary to ensure accuracy and reliability. For example, Figma's Stark plugin does already include a beta feature to test APCA as well
  • Ratios are quite different to current contrast ratio system, in short (taken from Dan Hollick's article):
    • 15 - 🚫 Minimum for non-text elements
    • 30 - ⚠️ Absolute min for any text
    • 45 - ‼️ Min for large text (the old 3:1)
    • 60 - ❗Min for body text (the old 4.5:1)
    • 75 - ✅ Preferred level for body text
  • Community and User Feedback: Engage with the user community and gather feedback on the effectiveness of the new contrast evaluation. Adjustments may be necessary based on real-world usage.

Codex Figma spec with exploration
https://www.figma.com/design/KoDuJMadWBXtsOtzGS4134/branch/DzSA7dk3Tt4tLGiSZmYuJl/%E2%9D%96-Codex-components?node-id=19273-1832&t=Go5JdyRVeyS2mhzf-0

Acceptance Criteria

  • The color palette should be evaluated using APCA to provide a more accurate assessment of perceptual contrast, improving the accessibility and usability of the system.
  • Integrate APCA: Implement APCA as (the primary) method for evaluating color contrast in the web application.
  • Monitor WCAG 3 Developments: Regularly check for updates to WCAG 3 and adjust the APCA implementation as needed.
  • Maintain or clarify WCAG 2 Support: Provide an option for users to view contrast evaluations based on WCAG 2 for backward compatibility.
  • User Education: Inform users about the benefits of APCA and how it improves accessibility.

Further reading

Event Timeline

Volker_E added a project: Accessibility.
CCiufo-WMF raised the priority of this task from High to Needs Triage.Feb 20 2024, 3:26 PM
CCiufo-WMF moved this task from Inbox to Backlog on the Design-System-Team board.
CCiufo-WMF lowered the priority of this task from High to Medium.Jul 22 2024, 5:32 PM

Summary from my POV: We're taking APCA for testing of closest critical color combinations into account in one of the upcoming sprints and might even amend some colors. But we stay as bound as we're currently do to WCAG 2.n with its contrast requirements as WCAG 3 is not yet a standard.

APCA requirements are not yet set in stone, but one thing is for sure that we probably need to start adjusting to already: From APCA's point of view, WCAG 2.1 is too tolerant for dark color pairs (as opposed to bright ones), and it's not unlikely that dark mode tokens will need a complete overhaul.

image.png (514×692 px, 119 KB)

(source)

An interesting observation made by one community member:

For my own analysis in Excel, I did completely random integers in the range 0-255 for both foreground and background colours. I ran circa 5000 combinations, obviously lots of these were completely nonsensical, but 1393 colour pairs were considered viable by one algorithm or the other. Of these,

  • 65.8% of the pairs were passed by both algorithms,
  • 27.9% incorrectly passed WCAG2, due to its issue with dark colour pairs.
  • 6.3% of the pairs incorrectly failed WCAG2, as this excessively penalises bright colour pairs.

On another note, if we strictly apply the requirements as they stand now, MediaWiki (Vector) doesn't come close to passing APCA – primarily due to font size restrictions where 14px Arial/Helvetica is basically only allowed for black on white and almost anything below 14px is outlawed. Even switching to 16px as default doesn't improve the situation much.

Just to give you a hint of how inadequate WCAG 2.1 is for dark color pairs compared to APCA:

WCAG 2.1APCA
image.png (28×127 px, 1 KB)
4.3737.2
image.png (30×125 px, 2 KB)
3.68-69.5 (the absolute value, 69.5, matters here)

WCAG 2.1 thinks the contrast is higher for black here, whereas APCA gives almost twofold advantage for white.

Recently, there was a backlash after an attempt of redesign of diffs in T361717. People noted a poor contrast of black on blue, but couldn't substantiate scientifically what's wrong with this:

image.png (234×1 px, 24 KB)

Indeed, APCA handles this color pair much better than WCAG 2.1 does, giving it a way lower relative value.

So, the considerations of moving away from WCAG 2.1 as an outdated standard are very practical.

That said, I honestly don't think that APCA should be applied in the way WCAG 2.1 was, if it becomes a standard in its current form. Right now it effectively outlaws any gray (deemphasized) text in a lot of designs widely used across the web on the basis that it is not pronounced enough (see image in T308772#10025899 and result for light mode's @color-subtle). But being not pronounced enough is the very point of gray text.

At the same time, it exempts placeholder and disabled text (well, like WCAG 2.1) from the requirements, only stating that it should have lightness contrast above 30 (which is lower than 2:1 of WCAG 2.1 for light color pairs). Setting an extermely low bar for placehodlers/disabled text and an extremely high bar for deemphasized text doesn't make sense to me.

As mentioned in the DST project page for color design documentation:

ACPA, or Advanced Perceptual Contrast Algorithm, takes into consideration font weight and size, color (or perceived lightness differences between two colors), and context (visual surroundings and intended purposes of text) to measure the visual accessibility of color. Though we have this current understanding of this form of color measurement in the future next version of WCAG 3, there is not enough information to influence a major affect on the current color expansion. Therefore, the way application colors will be applied at this point will continue to be based off of WCAG 2 standards and criteria.