Hi. I am using Custom Header Icons component.
I would like these to be white.
Hi. I am using Custom Header Icons component.
I would like these to be white.
It looks like the component uses an element with a class of custom-header-icon-link
to contain each icon. If youâre using svg icons, you should be able to target them like this:
.custom-header-icon-link svg {
stroke: white;
}
Sometimes svgs look like they are made of lines but theyâre actually made of filled-in shapes, so you might need to change the stroke: white
to fill: white
.
Hi, trying both of those still has them looking like this:
With the CSS you provided, no change happened.
Hmm, Iâm not sure whatâs going on there! You might double check to make the sure the icons are svgs and not image files. You could also try stroke: white !important;
in case thereâs some other styling overriding it.
One âsanity testâ I like to do with CSS when it doesnât seem to be doing anything is to add a background-color to the selector.
.custom-header-icon-link svg {
background-color: pink;
stroke: white;
}
This way If you donât see the background color, the problem might be that the selector isnât targeting the right element. In this case, the browserâs inspector tool is really handy because you can look at the hierachy of elements and get a better idea of how the selector should be written.
With Chrome, you can hit ctrl+shift+c and click on the icon to have it jump to that element in the list. If you want to post a screen shot of the elements tab, we could take a look at how things are organized. For instance, this is what it looks like for me when I try the component in preview:
Iâll try that when Iâm back home. Have tried to get this working for like 8hrs now background-color was one of the things I tried earlier and have messed with Inspect Element non-stop but still didnât work. Will try the âimportantâ thing later when home in a few hours and leave an update! And yes, theyâre 100% .SVG links.
Ah man, sounds frustrating!
One other technique that can be helpful for troubleshooting is to add styles directly the element in the inspector to see if that works (using the element.style part of the styles tab). Note: these are temporary changes that only affect the current window and are deleted when you refresh.
Here are my icons and here is the Inspect Element for them:
Iâve tried all the CSS coding you listed, both trying âstrokeâ and âfill.â The â!importantâ thing didnât work either. I have no idea whatâs causing this.
I might have stumbled upon something, though. I noticed that even though I am using .SVG âimagesâ, the Inspect Element is still showing them in an <img>
tag VS the <svg class="
that yours shows. Is this a bug with Custom Header Icons?
Aha, yeah looks like thatâs why the changes werenât doing anythingâthereâs no actual <svg>
tag. I donât think itâs a bug that the component put it in an <img>
tag. Thatâs just one of the ways to display an svg, but it does make it harder to style it. If you have access to the svg files themselves, you can change the stroke or fill color there (it would be an attribute like stroke="black"
, and there could be more than one).
If you canât edit the svg, you could try using css filters. These let you add certain visual effects to an element. Since they appear to be black now, we could try inverting them to get white.
.custom-header-icon-link img {
filter: invert(100%);
}
Note that the selector needs to be img instead of svg now