Skip to content

How to make SVGs respect light/dark mode? #2097

Answered by squidfunk
hellt asked this question in Q&A
Discussion options

You must be logged in to vote

This is possible:

  1. Include your logo as an icon, so it's inlined as an SVG by the theme (see docs)
  2. Remove all colors from the SVG logo, so you can use CSS to set the fill property (as with the Material logo)

To see it in action, go to the color setup guide and click on a light color, e.g. amber. Note that this will only work for a single color, i.e. you can fill to white or black, but you may use fill-opacity like I did in the Material logo.

Note that using this approach, you cannot change multiple colors. For that to work, you'd have to add two logos and toggle the display property dependent on the theme mode using some extra CSS.

The logo can be easily changed by overriding the logo.html

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by hellt
Comment options

You must be logged in to vote
2 replies
@squidfunk

This comment has been hidden.

@NicolasMassart
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants