Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change image based on white-/darkmode #4

Open
Mondei1 opened this issue Sep 4, 2024 · 0 comments
Open

Change image based on white-/darkmode #4

Mondei1 opened this issue Sep 4, 2024 · 0 comments

Comments

@Mondei1
Copy link

Mondei1 commented Sep 4, 2024

GitHub actually supports conditional images based on prefers-color-scheme.

See https://github.com/GiorgosXou/Random-stuff/tree/main/Programming/StackOverflow/Answers/70200610_11465149 for example or their Stackoverflow answer: https://stackoverflow.com/questions/65413712/changing-readme-md-image-display-conditional-to-github-light-mode-dark-mode

But here is a quick copy-paste from their answer:

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/GiorgosXou/Random-stuff/main/Programming/StackOverflow/Answers/70200610_11465149/w.png">
  <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/GiorgosXou/Random-stuff/main/Programming/StackOverflow/Answers/70200610_11465149/b.png">
  <img alt="Shows a black logo in light color mode and a white one in dark color mode." src="https://user-images.githubusercontent.com/25423296/163456779-a8556205-d0a5-45e2-ac17-42d089e3c3f8.png">
</picture>

I think this is very useful to include, as some logos look terrible with the wrong background color.

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

No branches or pull requests

1 participant