Feedback on new rust documentation logo background

Doing it with CSS sounds fairly straightforward: you can have two <img> tags for each logo type, set some CSS class adjacent to logo-container like logo-light or logo-dark, and use a child selector to make one of the two <img> tags either display: none or not.

I guess somehow in there something (JS) needs to toggle that CSS class, but I wasn't able to figure out how the existing theming works (I didn't see any other changes to the DOM when the themes are toggled on cursory inspection).

If themes were controlled only by prefers-color-scheme, then this would work automatically:

<picture>
   <source media="(prefers-color-scheme: dark)" src="dark-logo.png">
   <img src="light-logo.png">
</picture>

a JavaScript theme switcher could use this markup by manipulating the <source media> attribute (without media attr the first source becomes enabled).

<picture> element has an advantage of loading only the visible image, instead of both.

3 Likes

Thanks for doing this!

However, I think the default logo looks best on a dark background when inverted. If you only change the default logo, inverting it seems like the best solution to me.

1 Like

I personally prefer the outlined logo to the inverted one. The inverted logo stand out too much on a dark theme

Rather than attempting to bikeshed the easiest way to modify a Rust logo designed for a light background to work on a dark background, we should be asking the logo designer for a logo designed for a dark background.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.