fix(button): increase contrast#666
Conversation
Only secondary/plain, as primary uses white text color.
|
82f3524 was deployed to: https://fred-pr666.review.mdn.allizom.net/ |
|
Please update the plain button hover contrast in dark mode as well: /* Plain */
&[data-variant="plain"] {
&:hover {
-- background-color: light-dark(var(--color-gray-80), var(--color-gray-20));
++ background-color: light-dark(var(--color-gray-80), var(--color-gray-40));
}The current hover is almost not noticeable. In the following video, the button_contrast-2025-08-31_11.06.45.mp4In the above video, the buttons are zoomed in, but in the normal case hover color change is not visible. |
The suggestion passes WCAG AAA: @mdn/content-team Do you approve the changes in this PR, and/or Onkar's suggestion? |
|
Yes approve both 👍 |
|
I looked into applying @OnkarRuikar's suggestion, but noticed that all neutral dark variants have similar contrast issues, see the following screenshots, with hover on the middle button: Here's how these would look with increased contrast (1120399):
@Rumyra Does that look right? Edit: Contrast ratios are 12.35:1 and 7.39:1 respectively, both passing WCAG AAA. |
|
@caugner thanks for increasing the scope of the fix. The dark theme is looking good.
|
|
I'm thinking that we shouldn't mix these changes up in a single PR:
|
|
There are other places that could use more hover contrast: hoverContrast.mp4Also include the search box suggestion list and left sidebar list. In right sidebar in-viewport items could use more prominent blue background. |
Use `--color-green-20` as the default text color for `secondary` and `plain` positive buttons in light mode, lifting contrast on `--color-background-primary` from 3.81:1 (fails AA) to 7.74:1 (AAA). With the default color now matching the previous hover color, the hover `color` override is redundant and removed.
Use `--color-green-20` instead of `--color-green-10` as the dark-mode hover background for `secondary` and `plain` positive buttons. The previous `green-10` is darker than the page background (`gray-10`), making the hover state effectively invisible (1.10:1 luminance contrast vs page). `green-20` lifts that to 1.90:1 — still below the WCAG 1.4.11 3:1 threshold but materially more visible. Text contrast on the new hover background remains AA (5.54:1).
Avoid shadowing the outer `disabled` array declared at the top of the render function.
`disabled` is a non-standard attribute on `<a>`, so rendering a separate disabled-anchor section duplicates the non-disabled one visually while labeling both as `<a>`.







Description
Increases the contrast between the background color with/without hover, all while ensuring a visible hover effect.
Motivation
Resolve accessibility issues.
Additional details
As of 120d223:
WCAG contrast ratios
Legend: 🔴 fails AA (<4.5:1) · 🟠 passes AA (≥4.5:1) · 🟢 passes AAA (≥7:1) — thresholds for normal text.
Screenshots
Related issues and pull requests
Fixes #653.