Skip to content

fix: improve contrast for all links, button and label text#545

Merged
paddyroddy merged 3 commits intoUCL-ARC:mainfrom
cuteshaun:cuteshaun/fix-a11y-contrast-issues
Jun 10, 2025
Merged

fix: improve contrast for all links, button and label text#545
paddyroddy merged 3 commits intoUCL-ARC:mainfrom
cuteshaun:cuteshaun/fix-a11y-contrast-issues

Conversation

@cuteshaun
Copy link
Contributor

This PR improves dark mode accessibility to meet the minimum contrast ratio of 4.5:1.

Issues

  • Link text and underline colors in dark mode didn’t meet the 4.5:1 contrast ratio requirement.
  • Hover state on links was barely noticeable due to minimal styling difference.
  • Green and red labels didn’t provide enough contrast with white text.
  • The data-theme="dark" attribute was not consistently applied, causing dark mode styles to fail.

Changes

  • Updated dark mode link and underline colors for better contrast and visibility
  • Added hover underline animation (+1px thickness and offset)
  • Improved label background colors for accessibility
  • Introduced _sass/custom/variables.scss with named tokens ($link-color-dark, etc.)
  • Explicitly set data-theme attribute on based on a selected theme

Closes #535

Verified links contrast with the WCAG contrast checker tool

@cuteshaun
Copy link
Contributor Author

@samcunliffe, thanks for merging main into feature branch!

@samcunliffe
Copy link
Member

@samcunliffe, thanks for merging main into feature branch!

@cuteshaun, I'm sorry about the unfriendly contributor experience! Our CI was a bit misconfigured ❌❌.

@samcunliffe
Copy link
Member

Screencast: first tab is these changes, second tab is the current deployed version.

Screen.Recording.2025-06-10.at.07.10.07.mov

Looks really nice! Also improves the traffic lights' colour contrast.

Copy link
Member

@samcunliffe samcunliffe left a comment

Choose a reason for hiding this comment

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

Yeah, thanks again for the really nice and fast contribution!

Are you planning to attempt to get these changes in upstream? Let us know and we'll all thumbs-up your PR(s)!

Comment on lines +2 to +4
$blue-400: #4da6ff;
$green-700: #00755c;
$red-600: #d13c3c;
Copy link
Member

@samcunliffe samcunliffe Jun 10, 2025

Choose a reason for hiding this comment

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

Nice. Contrast ratios confirmed.

Dark-mode links are 5.87:1.
Traffic lights are now 5:61:1 and 4:74:1.

Screenshot 2025-06-10 at 07 18 39 Screenshot 2025-06-10 at 07 18 35

@samcunliffe samcunliffe added enhancement New feature or request website Related to https://github-pages.arc.ucl.ac.uk/python-tooling accessibility Something relating to the ease of accessibility (alt-text, colour choices, language, etc) labels Jun 10, 2025
@cuteshaun
Copy link
Contributor Author

cuteshaun commented Jun 10, 2025

Are you planning to attempt to get these changes in upstream? Let us know and we'll all thumbs-up your PR(s)!

Haha, thanks, really appreciate that! When you say “upstream,” do you mean the original repository for just the docs theme?

Copy link
Member

@paddyroddy paddyroddy left a comment

Choose a reason for hiding this comment

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

This is a really nice piece of work

Comment on lines +32 to +35
const theme = localStorage.getItem("theme") === "dark" ? "dark" : "light";
jtd.setTheme(theme);
setHtmlThemeAttr(theme);
toggleDarkMode.textContent = theme === "dark" ? "☼" : "☾";
Copy link
Member

Choose a reason for hiding this comment

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

This is so clean

@paddyroddy paddyroddy merged commit 046b0b9 into UCL-ARC:main Jun 10, 2025
16 checks passed
@samcunliffe
Copy link
Member

Are you planning to attempt to get these changes in upstream? Let us know and we'll all thumbs-up your PR(s)!

Haha, thanks, really appreciate that! When you say “upstream,” do you mean the original repository for just the docs theme?

Yes, exactly. There are a few PRs open, but I didn't spot anything specifically improving the accessibility (there are issues but no solutions afai can see).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accessibility Something relating to the ease of accessibility (alt-text, colour choices, language, etc) enhancement New feature or request website Related to https://github-pages.arc.ucl.ac.uk/python-tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change the dark-mode hyperlink colour for a higher contrast ratio and make all hyperlink underlines more visible

3 participants