• Hi, can you help me with simple css that can turn all SVGs white with transparent background on Dark Mode?

    Thank you

Viewing 1 replies (of 1 total)
  • Theme Author Blockify

    (@blockify)

    Hi @nadzrulhanif

    This is not a straight-forward thing to do, but you could try adding something like this:

    .is-style-dark svg {
        fill: #fff;
    }
    
    @media (prefers-color-scheme: dark) {
        svg {
            fill: #fff;
        }
    }

    This is just a workaround, the recommended way to do this is to use currentColor or the CSS custom properties directly in the SVG html. For example:

    <svg xmlns="https://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" fill="currentColor" height="22px" width="22px">
    <path d="M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z"></path>
    </svg>

    The CSS custom properties you could use instead are generated by the theme. These can also be used in the SVG fill attribute:

    var(--wp--preset--color--neutral-900)

    I hope this helps. Please let me know if you have any other questions.

Viewing 1 replies (of 1 total)
  • The topic ‘Custom CSS to turn all SVG default Black, Dark Mode = White’ is closed to new replies.