Change svg color based on the selected mode (dark/light) #1130
-
I have many svg images in my application. Now I want the to be able to switch their color according to the selected color scheme which u can change in the top (dark/light). So I tried using a <style> segment inside my svg. As this svg is not part of the DOM this approach does not work. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Probably do it like GitHub used to do? 
 And add this to your styles: :root.dark [src$="#light-mode-only"] {
display: none;
}
:root:not(.dark) [src$="#dark-mode-only"] {
display: none;
} |
Beta Was this translation helpful? Give feedback.
-
I've used filter: invert to invert svg images according to the selected color scheme. :root.dark img[src$=".svg"] {
filter: invert(1);
}
:root:not(.dark) img[src$=".svg"] {
filter: invert(0)
} |
Beta Was this translation helpful? Give feedback.
Probably do it like GitHub used to do?
And add this to your styles: