Skip to content

Comments

fix(a11y): improve non-text (border) colour contrast#1625

Draft
knowler wants to merge 1 commit intomainfrom
knowler/non-text-contrast-increase-border-tokens
Draft

fix(a11y): improve non-text (border) colour contrast#1625
knowler wants to merge 1 commit intomainfrom
knowler/non-text-contrast-increase-border-tokens

Conversation

@knowler
Copy link
Member

@knowler knowler commented Feb 24, 2026

Doesn’t completely resolve #1510, but it does have a wide effect on a lot of components (e.g. search boxes, buttons, etc.) that would be failing (and causes them to pass).

As stated in #1510, we are currently failing WCAG 2.2 SC 1.4.11 (Level AA) which requires a minimum non-text colour ratio of 3:1 for user interface components and graphical objects. This was most notable for the search field and buttons.

This PR increases the lightness channels of the --border and --border-hover values for the light and dark colour schemes which in effect causes their contrast on the main background to just pass 3:1. The original issue did include the ratios of the borders and the inner surface (i.e. the background colour of the component itself). For buttons, I don’t think this is necessary. For text fields, this maybe necessary unless there are other visual elements within the border (e.g. our main search field has the leading ./).

Admittedly, just increasing the border contrast alone isn’t a great design decision. Adding other visual effects could help, but it would be a bit of a departure from the current design paradigm. There’s also the issue of pairing these border colours with different background colours—there could be failures.

Before After
The original, dark mode, cropped view of the main logo and search on the homepage. Contrast ratio: 1.257:1 (#262626 / #101010) The increased-contrast, dark mode, cropped view of the main logo and search on the homepage. Contrast ratio: 3.167:1 (#636363 / #101010)
The original, light mode, cropped view of the main logo and search on the homepage. Contrast ratio: 1.574:1 (#CECECE / #FFFFFF) The increased-contrast, light mode, cropped view of the main logo and search on the homepage. Contrast ratio: 3.033:1 (#949494 / #FFFFFF)
Full page comparison of home and package views

Ignore other non-border-contrast visual differences. I’ve got screenshots of different builds. This is tedious work.

Before After
The original, dark-mode, home page, full screenshot The increased-contrast, dark-mode, home page, full screenshot
The original, light-mode, home page, full screenshot The increased-contrast, light-mode, home page, full screenshot
The original, dark-mode, package page, full screenshot The increased-contrast, dark-mode, package page, full screenshot
The original, light-mode, package page, full screenshot The increased-contrast, light-mode, package page, full screenshot

@knowler knowler requested a review from alexdln February 24, 2026 15:07
@vercel
Copy link

vercel bot commented Feb 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Feb 24, 2026 3:07pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Feb 24, 2026 3:07pm
npmx-lunaria Ignored Ignored Feb 24, 2026 3:07pm

Request Review

@codecov
Copy link

codecov bot commented Feb 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

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.

Non-text contrast is not sufficient (almost everywhere)

1 participant