Problem/Motivation

Originally reported by @smustgrave: #3604037-28: Indicate that grouping elements have child element errors for UX and a11y.

In dark mode, labels for invalid form fields have too low contrast (4.47:1). Results on WebAIM Contrast Checker.

WCAG: SC 1.4.3 Contrast (Minimum) (Level AA)

Steps to reproduce

  1. Standard installation.
  2. Use dark mode (set browser or system preferences to prefer dark, or emulate prefers-color-scheme: dark in devtools).
  3. Go to /user/login while logged out. This should be a login form.
  4. Click the Log in button without entering any username / password.
    This should create form validation errors and red labels for the invalid fields.
  5. Run a scan with the Axe DevTools or Accessibility Insights browser extensions.

Expected

All red error text has contrast ratio of 4.5:1.

Actual

The red field labels fail color contrast checks.

Errors on login form in dark mode with contrast failures highlighted.

Proposed resolution

  • Use a color for error form labels that has a contrast ratio of at least 4.5:1 against the background.
    Suggested: #d67a7a.
  • IMO, use the same color for field borders, etc for consistency.
    Field borders do pass with the current color because non-text contrast requires a lower ratio, but consistency would probably be desirable.

Here's a before / after screenshot from #ce6060 to#d67a7a.

It has 4.71:1 contrast on the WebAIM Contrast Checker and passes the browser extension test.

Comparison of current error color to that in the MR, on the login form

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3625458

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

kentr created an issue. See original summary.

kentr’s picture

Issue summary: View changes
StatusFileSize
new61.73 KB
kentr’s picture

Though, when I tested #f39b9d I did not check its contrast with the non-error label color.

That's too low, so #f39b9d won't work.

kentr’s picture

StatusFileSize
new143.28 KB

Even the current color doesn't have 4.5:1 contrast to the non-error label color...

Here's a proposal, before / after from 59% to 60% lightness (from #ce6060 to#cf6363). It has 4.6:1 contrast on the WebAIM Contrast Checker.

edit: And it passes the browser extension test.

Before & after of form errors on the login form.

kentr’s picture

StatusFileSize
new62.93 KB

Replacing previous image with cropped version.

kentr’s picture

Issue summary: View changes
Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Needs work
StatusFileSize
new141.29 KB

Tested this with a color contrast tool and still fails AA :(

fail

smustgrave’s picture

What about #e27878? I asked claude for a good contrast for the 2nd value and this passes AA

kentr’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new72.45 KB
new41.92 KB

Sorry about that! The login form I tested has a darker background color for the fields: #1b1b1d.

On other forms with the lighter background, slightly increasing the lightness of the original to #d67a7a passes with the Axe browser extensions and the WebAIM Contrast Checker (ratio: 4.71:1).

I made that change in the MR. I defer to others on the color choice.

Before / after screenshots comparing main to the MR with #d67a7a:

At /user/login:

Comparison of current error color to that in the MR, on the login form

At /node/add/article:

Comparison of current error color to that in the MR, on the node edit form

I also tried the very similar color used in --admin-color-bg-error (#de7560), but it was more orange and looked odd to me.

kentr’s picture

Issue summary: View changes

Screenshot of the results for the MR in the WebAIM Contrast Checker, FTR:

Only local images are allowed.

Also updated the STR.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new142.21 KB

Passes!

passes

rkoller’s picture

one general concern i've voiced over in #3604037-45: Indicate that grouping elements have child element errors for UX and a11y and #3604037-47: Indicate that grouping elements have child element errors for UX and a11y and @kentr asked to raise it over in this issue as well. problem is the default admin theme has a red accent color and that red might be close either in light mode and/or dark mode. i am uncertain if it is a good idea having an accent color being close to the one color signifying errors in a form...

mgifford’s picture

In a new issue, I think it would be good to raise this and propose a new color (or. a process for identifying a new accent color).