fix(Avatar): use light-dark() for fallback initials to pass WCAG AA contrast in dark mode - #5321
fix(Avatar): use light-dark() for fallback initials to pass WCAG AA contrast in dark mode#5321Abidit wants to merge 2 commits into
Conversation
…ontrast in dark mode Fallback initials used --color-text-secondary on --color-neutral which fails WCAG AA (4.5:1) in dark mode at 4.27:1. Switch to light-dark() so dark mode uses --color-text-primary (7.25:1) while light mode keeps --color-text-secondary (5.42:1), matching the existing convention in useTableStickyColumns.tsx. Fixes facebook#5279
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Hi @Abidit! Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
Hi @Abidit! Nice catch and thank you for putting up this fix! Using Just a few small things that might help get this PR merge-ready:
'@astryxdesign/core': patch[fix] Avatar: resolve fallback initials and default icon color via light-dark() to meet WCAG AA contrast in dark mode (#5279)
color: `light-dark(${colorVars['--color-text-secondary']}, ${colorVars['--color-text-primary']})`,
|
- Use colorVars token references instead of raw CSS strings - Add WCAG AA contrast regression tests for Avatar and AvatarGroupOverflow - Fix AvatarGroupOverflow +N indicator with same light-dark() approach - Add changeset for patch release
Thanks for the detailed review! I've addressed all four points:
|
Summary
Fixes #5279
Avatar's fallback initials (shown when no image is set) used
--color-text-secondaryon--color-neutralbackground, whichfails WCAG AA contrast (4.5:1) in dark mode at 4.27:1.
Fix
Switch to
light-dark()so each color mode gets the appropriatetext color:
--color-text-secondary→ 5.42:1 ✅ (unchanged)--color-text-primary→ 7.25:1 ✅ (was 4.27:1 ❌)This matches the existing convention in
useTableStickyColumns.tsx.Change
One line changed in
Avatar.tsx: