Skip to content

fix: WCAG 2.1 AA contrast failures in core color tokens (#3654) - #4022

Closed
gonzoblasco wants to merge 5 commits into
meta:mainfrom
gonzoblasco:fix/wcag-contrast-tokens
Closed

gonzoblasco wants to merge 5 commits into
meta:mainfrom
gonzoblasco:fix/wcag-contrast-tokens

Conversation

@gonzoblasco

@gonzoblasco gonzoblasco commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

What

Fixes a WCAG 2.1 AA non-text contrast failure reported in #3654: --color-border-emphasized was below the 3:1 minimum against standard surface/body backgrounds.

Change

--color-border-emphasized is an active border (focused inputs, active cards, emphasized states), not a disabled token. At 1.37:1 on light backgrounds it was barely perceptible - a genuine bug, failing SC 1.4.11 (Non-text Contrast, 3:1 minimum) for active UI components.

  • Light: #CCD3DB → #898D93 (3.02:1 on body, was 1.37:1)
  • Dark: #494D53 → #6E7276 (3.00:1 on popover, was 1.71:1)

Scope note (updated after review)

The original PR also proposed changes to --color-text-disabled and --color-icon-disabled. Per review feedback (@ernestt), those are exempt under WCAG SC 1.4.3 (text in inactive UI components), so both were reverted. This PR now contains only the --color-border-emphasized fix.

Methodology

Values computed with the WCAG 2.1 relative luminance formula, maintaining hue while adjusting luminance - the same contrast-measurement approach the component audits (#5332) use.

Validation

  • 521/521 tests pass
  • pnpm lint: clean
  • pnpm check:sync: clean
  • pnpm check:package-boundaries: clean

Fixes #3654

@vercel

vercel Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
astryx Error Error Aug 27, 2026 6:48pm

Request Review

@meta-cla

meta-cla Bot commented Jul 16, 2026

Copy link
Copy Markdown

Hi @gonzoblasco!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge needs:design-review Affects visuals — Design should review labels Jul 16, 2026
@meta-cla

meta-cla Bot commented Jul 16, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 16, 2026

@ernestt ernestt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our understanding is that disabled text and buttons are exempt from the contrast requirements

@gonzoblasco gonzoblasco left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review, @ernestt.

You're right that WCAG 2.1 SC 1.4.3 explicitly exempts "text that is part of an inactive user interface component" from contrast requirements. I should have separated the concerns more clearly in the PR.

Let me break down the three tokens:

--color-text-disabled - Fair point. This is exempt under SC 1.4.3. Happy to revert this to the original values if that's the team's preference.

--color-icon-disabled - Also debatable under SC 1.4.11. If the icon is purely decorative or part of a disabled/inactive control, the exemption applies. I'd lean toward reverting this one too.

--color-border-emphasized - This one is different. It's not a disabled token - it's an active border used for emphasized states (focused inputs, active cards, etc.). At 1.37:1 on light backgrounds, it's barely perceptible and fails SC 1.4.11 (Non-text Contrast, 3:1 minimum) for active UI components. This is a genuine bug, not a design preference.

So my proposal: revert --color-text-disabled and --color-icon-disabled to their original values, and keep only the --color-border-emphasized fix. Or if you'd prefer, I can split this into a smaller PR that only addresses --color-border-emphasized.

What do you think?

gonzoblasco

This comment was marked as duplicate.

@gonzoblasco

Copy link
Copy Markdown
Contributor Author

Updated per review feedback: reverted --color-text-disabled and --color-icon-disabled to their original values, keeping only the --color-border-emphasized fix.

As discussed, disabled tokens are exempt under WCAG 2.1 SC 1.4.3/1.4.11. The border-emphasized token is an active UI component that genuinely fails SC 1.4.11 (Non-text Contrast) at 1.37:1 on light backgrounds.

Ready for re-review.

Fixes three tokens that failed WCAG 2.1 AA contrast ratios against
standard surface/body/popover backgrounds:

- --color-text-disabled: light #A4B0BC → #697078 (4.54:1 on body),
  dark #6F747C → #8C9096 (4.53:1 on popover)
- --color-icon-disabled: light #A4B0BC → #858E98 (3.01:1 on body)
- --color-border-emphasized: light #CCD3DB → #898D93 (3.02:1 on body),
  dark #494D53 → #6E7276 (3.00:1 on popover)

All values computed using the WCAG 2.1 relative luminance formula,
maintaining the original hue while adjusting luminance.

Tests: 521/521 pass (13 test files)
As discussed with @ernestt: disabled text and icons are exempt from
WCAG 2.1 SC 1.4.3/1.4.11 contrast requirements. Keeping only the
--color-border-emphasized fix, which is an active UI token that
genuinely fails SC 1.4.11 (Non-text Contrast) at 1.37:1 on body.
@gonzoblasco

Copy link
Copy Markdown
Contributor Author

Hi @ernestt and team - following up on the earlier review.

I've updated the PR body to reflect the current state. Per the feedback on disabled tokens (exempt under SC 1.4.3), I reverted both --color-text-disabled and --color-icon-disabled. The PR is now scoped to a single change: --color-border-emphasized, which is an active border (focused inputs, active cards), not a disabled token, and fails SC 1.4.11 at 1.37:1.

A couple of things that may help with the review:

  • Methodology consistency with the component audits. The measurement approach here (WCAG 2.1 relative luminance, hue-preserving luminance adjustment) is the same one the component audits use - e.g. fix(breadcrumbs): audit pass, hit target, theme targets, focus ring, RTL separator guidance #5332 (Breadcrumbs) measures contrast the same way and cites these token ratios. The audit-contrast.mjs script included here is reproducible.
  • Scope is now minimal: 3 files (1 token change + 2 audit scripts), no unrelated edits.

Would appreciate a re-review when you get a chance. Happy to split the audit scripts into a separate PR if the team prefers the token change alone.

github-actions Bot added a commit that referenced this pull request Aug 27, 2026
@github-actions

github-actions Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.8KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

Status: Skipped — Broad stable scope is deferred to the daily release gate. It covers 974 trusted baseline shots instead of recapturing them for this PR. View the report


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for narrowing this after @ernestt's review; reverting the disabled-token changes addressed that concern. The emphasized-border update is separable and aligns with the 3:1 non-text contrast contract.

Please remove the two unnecessary executable additions, scripts/audit-contrast.mjs and scripts/find-compliant-colors.mjs, and leave the base-theme token update as the focused change. If you'd rather talk it through with someone, we're in Discord.

[Reviewed by Robohands]

Keep the PR focused on the base-theme token change per review feedback.
@gonzoblasco

gonzoblasco commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor Author

@cixzhang, done - removed scripts/audit-contrast.mjs and scripts/find-compliant-colors.mjs. The PR now contains only the --color-border-emphasized token change in packages/core/src/theme/tokens.stylex.ts.

github-actions Bot added a commit that referenced this pull request Aug 27, 2026

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, both scripts are gone, clearing my previous block. The token change looks good. Before merge, please regenerate tokens.doc.mjs and remove stale script references from the PR body.

[Reviewed by Robohands]

@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Aug 27, 2026
@gonzoblasco

Copy link
Copy Markdown
Contributor Author

Both items are done:

  • Regenerated tokens.doc.mjs - it now reflects the updated --color-border-emphasized values (#898D93 / #6E7276).
  • Removed the stale script references from the PR body (the audit-contrast.mjs / find-compliant-colors.mjs mentions in Methodology and the Scope note).

The PR is now scoped to just the base-theme token change. Checks are re-running on the latest commit.

github-actions Bot added a commit that referenced this pull request Aug 27, 2026

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the generated token docs now match the source and the stale script references are gone, clearing both notes from my prior approval.

[Reviewed by Robohands]

@cixzhang

Copy link
Copy Markdown
Contributor

Thank you for the audit and the careful revisions. Color-token contrast work needs coordinated accessibility and design ownership rather than parallel implementation PRs. #3654 is assigned to @rubyycheung and the program is tracked in #4475, so we are closing this attempt.

@cixzhang cixzhang closed this Aug 28, 2026
@gonzoblasco
gonzoblasco deleted the fix/wcag-contrast-tokens branch August 28, 2026 01:38

This branch had an error being deployed

1 failed deployment
Preview — b5aac840 Deployed Aug 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team) needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Widespread WCAG 2.1 AA colour contrast failures across Design System, accessibility

3 participants