Skip to content

Fix inconsistent hover effects on dark-background elements#9383

Open
SanskaarUndale21 wants to merge 2 commits into
dart-lang:masterfrom
SanskaarUndale21:fix/hover-effects-8886
Open

Fix inconsistent hover effects on dark-background elements#9383
SanskaarUndale21 wants to merge 2 commits into
dart-lang:masterfrom
SanskaarUndale21:fix/hover-effects-8886

Conversation

@SanskaarUndale21
Copy link
Copy Markdown

@SanskaarUndale21 SanskaarUndale21 commented May 8, 2026

Summary

Fixes #8886

Several elements on pub.dev sit on permanently-dark surfaces (site header, footer, home banner, nav dropdown popup) but inherited the global a hover rule that applies brightness(80%) in light mode. This dimmed already-bright text on those dark backgrounds, reducing readability and producing an inconsistent experience across color themes.

  • Site header logo: overrides light-mode hover to brightness(120%) so the logo brightens (matching the desired dark-mode behavior) instead of dimming on the always-dark header background.
  • .nav-button (My pub.dev / Help buttons): replaces opacity: 0.8 dimming on hover with filter: brightness(120%) to be consistent with how other header elements respond to hover.
  • Nav popup links (.nav-link): overrides light-mode hover to brightness(120%) -- the popup always has a dark background regardless of theme.
  • Footer links: overrides light-mode hover to brightness(120%) -- the footer always has a dark background.
  • Home banner links: overrides light-mode hover to brightness(120%) -- the banner always has a dark background.
  • Monochrome icon links: adds a CSS :has() rule that suppresses the brightness filter on any <a> that directly wraps a .pub-monochrome-icon. Those icons already have their own opacity-based hover feedback (via .pub-monochrome-icon-hoverable); applying both mechanisms together produced a compounded, unintended visual effect.

Test plan

  • In light mode: hover the site logo, "My pub.dev" / "Help" buttons, nav popup links, footer links, and home banner links -- each should brighten rather than dim.
  • In dark mode: behavior for all the above is unchanged (already used brightness(120%) or no filter).
  • Hover the RSS feed icon link on the versions tab -- should show only the opacity-based feedback from .pub-monochrome-icon, no brightness filter applied on top.
  • All other links on light-background page content are unaffected (global brightness-on-hover still applies).

…#8886)

Several elements sit on permanently-dark surfaces (site header, footer,
home banner, nav popup) but inherited the global link hover rule that
applies brightness(80%) in light mode, dimming already-bright text and
reducing readability. Override those specific contexts to use
brightness(120%) so hovering always increases visibility regardless of
the active color theme.

Also replace the opacity: 0.8 dimming on .nav-button hover with a
brightness filter to stay consistent with the rest of the header.

Finally, suppress the brightness filter on anchor elements that directly
wrap a .pub-monochrome-icon, since those icons already have their own
opacity-based hover feedback and applying both mechanisms produced an
unintended compounded visual effect.

Fixes dart-lang#8886
@isoos
Copy link
Copy Markdown
Collaborator

isoos commented May 12, 2026

@SanskaarUndale21: thanks for filing this. I've tested the change locally, and while the top-left logo update was better, the other changes were not noticeable or were worse (e.g. hovering on footer links not stand out).

I think we may need to define a semantic CSS class that says "this has a dark background" regardless of the theme, and apply these rules on it.

Would you be interested in splitting the PR and/or creating the above CSS class? (no worries if not, I can do the refactor).

@SanskaarUndale21
Copy link
Copy Markdown
Author

Ok sure we can work on tht semantic CSS class

And i dont mind splitting the PR

@SanskaarUndale21
Copy link
Copy Markdown
Author

I will start working on the semantic CSS class

Replaces per-element light-theme overrides scattered across
_site_header.scss, _footer.scss, and _home.scss with a single
.pub-dark-bg rule in _base.scss. Applies the class to site-header,
site-footer, and _banner-bg in the Dart templates.
@SanskaarUndale21
Copy link
Copy Markdown
Author

SanskaarUndale21 commented May 12, 2026

@isoos

Done just pushed the refactor.

Created a .pub-dark-bg semantic CSS class in _base.scss with a single rule:

.light-theme .pub-dark-bg a:hover {
  filter: brightness(120%);
}

Applied the class to the three always-dark surfaces in the Dart templates:

  • site-header div
  • <footer> element
  • _banner-bg div (covers home banner and search bar)

Removed all the scattered .light-theme &:hover overrides that were previously duplicated across _site_header.scss, _footer.scss, and _home.scss. The .nav-hover-popup links are covered automatically since they are descendants of .site-header.

The .nav-button brightness change (opacity: 0.8 -> filter: brightness(120%)) is kept as-is since it is a <button> element, not an <a>, so the class rule does not apply there.

let me know if i have went wrong and what is needed to be improved if there are any mistakes

@SanskaarUndale21
Copy link
Copy Markdown
Author

SanskaarUndale21 commented May 12, 2026

@isoos

if there are some mistakes do tell me and if possible give me some photos of what exactly am i suppose to 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.

List, review and fix inconsistent hover effects

2 participants