Skip to content

Instantly share code, notes, and snippets.

@JamesGelok
Last active August 16, 2021 23:32
Show Gist options
  • Save JamesGelok/0c88dfe31f786609bb57b62e32f2a149 to your computer and use it in GitHub Desktop.
Save JamesGelok/0c88dfe31f786609bb57b62e32f2a149 to your computer and use it in GitHub Desktop.
Read me with light mode vs dark mode

Example

Hard refresh after changing modes to see the image change from light mode to dark mode:

Image is hosted at this gist.

SVG Code is below:

<svg fill="none" xmlns="http://www.w3.org/2000/svg">
  <style>
    .light-text {
      fill: black;
    }
    .dark-text {
      fill: white;
    }
    .light-mode-only {
      display: unset;
    }
    .dark-mode-only {
      display: none;
    }
    @media (prefers-color-scheme: dark) {
      .light-mode-only {
        display: none;
      }
      .dark-mode-only {
        display: unset;
      }
    }
  </style>
  <text x="25px" y="25px" class="dark-mode-only dark-text">You're Using Dark Mode</text>
  <text x="25px" y="25px " class="light-mode-only light-text">You're Using Light Mode</text>
</svg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment