Skip to content

Instantly share code, notes, and snippets.

@adamhopkinson
Created September 11, 2021 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamhopkinson/d3cadab0b8958ec81b928f4189a557c1 to your computer and use it in GitHub Desktop.
Save adamhopkinson/d3cadab0b8958ec81b928f4189a557c1 to your computer and use it in GitHub Desktop.
# Favicons with light/dark mode colour scheme
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@adamhopkinson
Copy link
Author

adamhopkinson commented Sep 11, 2021

Favicons with light/dark mode colour scheme

Use a style block in the svg which applies colours based on @media (prefers-colour-scheme):

        @media (prefers-color-scheme: light) {
            rect {
                fill: #333;
            }
            path {
                fill: #fff;
            }
        }
        @media (prefers-color-scheme: dark) {
            rect {
               fill: #fff;
            }
            path {
                fill: #333;
            }
        }

Have a look at the source of favicon.svg to see the details.

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