Skip to content

Fix WCAG 2.2 AA contrast failures in light and dark mode - #2050

Open
Double77x wants to merge 1 commit into
ImranR98:mainfrom
Double77x:fix/wcag-aa-contrast
Open

Double77x wants to merge 1 commit into
ImranR98:mainfrom
Double77x:fix/wcag-aa-contrast

Conversation

@Double77x

@Double77x Double77x commented Nov 26, 2026 •

Copy link
Copy Markdown

Fix WCAG 2.2 AA contrast failures in light and dark mode

Closes #2049

Summary

The site fails WCAG 2.2 Level AA colour contrast (1.4.3) in both colour schemes, and /apps has two small non-contrast issues as well. This PR fixes them with 29 added and 25 removed lines across 7 files. The change is two neutral text tokens, one new control-border token, one new warning token, and a handful of class swaps. No primary or brand colour is redefined, no component is restructured, and nothing new is installed.

Before this change axe reported 38 color-contrast nodes on / in light mode and 245 on /apps in light mode. Lighthouse scored 95 on / and 91 on /apps in dark mode. After this change axe reports 0 violations on 8 routes in both schemes, and Lighthouse scores 100 on both pages.

Screenshots

Both sheets show the same viewport region captured before and after. Each element is labelled with its measured ratio.

compare-apps-dark compare-apps-light

The change is a contrast shift, so at full-page scale it reads as slightly crisper text rather than a redesign. The sheet crops make it visible on card subtitles and install counts, the A to Z filter chips, the search placeholder, and the filter panel labels.

What changed, file by file

File Change Why
src/styles/global.css --color-text-muted moves from #7B7883/#938F99 to #5A5761/#B7B4BE. --color-text-subtle moves from #9F9BA3/#787579 to #6B6973/#A19EA8. --color-border-strong is new at #85828F/#A5A1AC, and --color-warning is new at #7C4A02/#FCD34D. The two text tokens account for almost every contrast failure. The border token gives form controls a 3:1 boundary under 1.4.11. The warning token replaces a hardcoded yellow that only worked in one scheme.
src/components/FilterForm.astro The search input, both selects, and the radios use border-border-strong. The placeholder moves from placeholder-text-subtle to placeholder-text-muted. Control outlines were 1.32:1 in light mode and 2.92:1 in dark mode against their fill. The placeholder was 2.21:1 and 2.03:1.
src/components/AppCard.astro Card titles move from h3 to h2. The sr-only <h1> for Apps was skipping to h3, which tripped heading-order.
src/components/Pagination.astro The arrow links get aria-label="Previous page" and aria-label="Next page". They were icon-only links with no accessible name, which fails link-name under 2.4.4 and 4.1.2.
src/pages/apps.astro The results header text moves from text-primary-300 to text-primary-600. The error banner uses bg-error/10 border-error/30 text-error. The empty-state heading moves from h3 to h2. text-primary-300 was 3.68:1 in light mode and 2.76:1 in dark mode. The red banner was 1.98:1. The heading level is fixed for the same reason as above.
src/pages/redirect.astro The <noscript> banner and the intent-blocked banner use the warning token. The error banner uses the error token. The app link moves from primary-400 to primary-600. The how-to-use heading moves from h3 to h2. The reasons match /apps, and the app link was 3.90:1 in dark mode. The yellow-on-yellow and red-on-red banners were the worst combinations on the site.
src/layouts/Layout.astro The header title and footer link hover colours move from primary-400 to primary-600. In dark mode the header hover was 3.90:1 against #2B2930. Both hovers now use an existing darker step at 9.17:1 in light mode and 8.42:1 in dark mode. axe cannot exercise hover-only colours.

No --color-primary-* or --color-brand value changes. The primary palette is only used differently in three places, and each one moves to an existing darker step.

Contrast, before and after

Token Mode Before After
--color-text-muted light 3.76:1 on the chip fill #F0EEF6 6.15:1
--color-text-subtle light 2.48:1 on the page fill #F5F3FA 4.90:1
--color-text-muted dark 3.87:1 on the chip fill #36343B 6.01:1
--color-text-subtle dark 3.16:1 on the card fill #2B2930 5.45:1
--color-border-strong (new) light 1.32:1 for --color-border-hover on its fill 3.04:1 to 3.76:1 under 1.4.11
--color-border-strong (new) dark 2.92:1 for --color-border-hover on its fill 3.65:1 to 5.67:1 under 1.4.11
--color-warning (new) both 1.13:1 in light mode for text-yellow-400 on bg-yellow-900/20, and 8.42:1 in dark mode 6.36:1 in light mode and 7.78:1 in dark mode on its 10% tint
--color-error (now used) both 1.98:1 in light mode for text-red-400 on bg-red-900/20, and 4.84:1 in dark mode 5.54:1 in light mode and 6.74:1 in dark mode on its 10% tint

Values are the worst rendered pairing for each token. They were measured from computed styles with translucent backgrounds composited from the bottom up. The ramp keeps its order (text, secondary, muted, subtle) so the hierarchy is unchanged, and each step simply sits further from the surface behind it.

Verification

Check Result
axe (WCAG 2.1 and 2.2, A and AA) 0 violations on 8 routes in both light and dark mode. The routes are /, /apps, /apps?category=games, /apps?category=, /apps?q=obtainium, /apps?sort=name&page=2, /redirect, and /redirect?r=....
Lighthouse accessibility 100 on / and /apps, up from 95 and 91
npm run typecheck pass
npm run build pass
npm test pass, with 8 of 8 site tests green

Deliberately not changed

  • Card outlines stay below 3:1. They are decorative container borders rather than control boundaries, so 1.4.11 does not apply. Raising them would put a heavy outline on every card.
  • The region landmark finding is axe best practice rather than A or AA, so it is out of scope here.
  • There are no layout, spacing, typography, or component API changes. The only visible difference is the shade of secondary text and control outlines.

Reviewer notes

  • Dark mode is driven by prefers-color-scheme and there is no in-page toggle, so every dark result came from emulating the media feature in the browser.
  • --color-text-subtle now clears 4.5:1 on cards and on the page. It does not clear 4.5:1 on surface-alt at 4.36:1 in light mode and 3.51:1 in dark mode. Nothing uses that pairing, because the placeholder moved to text-muted for exactly this reason, so it should stay that way.
  • axe cannot exercise hover-only colours, so the header, footer, and redirect-link hovers were checked by hand.
  • The /apps error banner is only reachable when the backend fails. It is fixed in CSS but not covered by the automated run.

Adjust two neutral text tokens, add a control-border token and a warning
token, and swap a few primary shades in markup so text and control
boundaries clear their WCAG minimum. No primary or brand colour values change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Colour Contrast - WCAG 2.2 AA Compliance

1 participant