I am trying to see if there is a way to force currentColor for an iconset.
From what I could read, when applying multiple css instruction, when they are targetting the same attributes, the last declaration supersedes the previous one.
So here's what I ended up doing:
- Creating an iconset
- Declaring two styles (id="dark" and id="light")
- Within these styles:
- Redefine the color variable (e.g.
svg {color: #61d0ff;}) - While I was at it, I also created a style for duotone icons (e.g.
.fill-duotone { fill: #61d0ff; opacity: 0.4; }) with the objective to replace attributesopacity="0.2"byclass=fill-duotone. - Colors are defined with different values in dark and light styles.
- Redefine the color variable (e.g.
Here's what the XML looks like:
<?xml version="1.0" encoding="utf-8"?>
<iconset name="test-duotone">
<display_name>test-duotone</display_name>
<set size="svg">
<style id="dark">
svg {
color: #61d0ff;
}
.fill-duotone {
fill: #61d0ff; /* Équivalent à l'attribut fill */
opacity: 0.4; /* Vous pouvez aussi gérer l'opacité ici si vous le souhaitez */
}
</style>
<style id="light">
svg {
color: #d17315;
}
.fill-duotone {
fill: #d17315; /* Équivalent à l'attribut fill */
opacity: 0.4; /* Vous pouvez aussi gérer l'opacité ici si vous le souhaitez */
}
</style>
<icon name="acorn-duotone">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
<rect width="256" height="256" fill="none"/>
<path d="M216,112v16c0,53-88,88-88,112,0-24-88-59-88-112V112Z" class="fill-duotone"/>
<path d="M216,112v16c0,53-88,88-88,112,0-24-88-59-88-112V112" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
<path d="M80,56h96a48,48,0,0,1,48,48v0a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8v0A48,48,0,0,1,80,56Z" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
<path d="M128,56V48a32,32,0,0,1,32-32" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
</svg>
</icon>
<icon name="address-book-duotone">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
<rect width="256" height="256" fill="none"/>
<path d="M208,32H64a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H208a8,8,0,0,0,8-8V40A8,8,0,0,0,208,32ZM136,144a32,32,0,1,1,32-32A32,32,0,0,1,136,144Z" class="fill-duotone"/>
<circle cx="136" cy="112" r="32" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
<line x1="32" y1="72" x2="56" y2="72" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
<line x1="32" y1="128" x2="56" y2="128" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
<line x1="32" y1="184" x2="56" y2="184" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
<path d="M88,168a60,60,0,0,1,96,0" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
<rect x="40" y="48" width="192" height="160" rx="8" transform="translate(264 -8) rotate(90)" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
</svg>
</icon>
<icon name="address-book-tabs-duotone">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
<rect width="256" height="256" fill="none"/>
<path d="M48,40a8,8,0,0,0-8,8V208a8,8,0,0,0,8,8H184V40Zm64,104a24,24,0,1,1,24-24A24,24,0,0,1,112,144Z" class="fill-duotone"/>
<line x1="184" y1="160" x2="216" y2="160" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
<line x1="184" y1="96" x2="216" y2="96" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
<rect x="40" y="40" width="176" height="176" rx="8" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
<circle cx="112" cy="120" r="24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
<path d="M80,168c3.55-13.8,17.09-24,32-24s28.46,10.19,32,24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
<line x1="184" y1="40" x2="184" y2="216" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
</svg>
</icon>
<icon name="air-traffic-control-duotone">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
<rect width="256" height="256" fill="none"/>
<path d="M66.19,160a8,8,0,0,1-7.52-5.27l-26.18-72A8,8,0,0,1,40,72H216a8,8,0,0,1,7.52,10.73l-26.18,72a8,8,0,0,1-7.52,5.27Z" class="fill-duotone"/>
<line x1="128" y1="72" x2="128" y2="24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
<path d="M104,24h48" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
<polyline points="168 72 152 160 152 232" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
<polyline points="88 72 104 160 104 232" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
<path d="M66.19,160a8,8,0,0,1-7.52-5.27l-26.18-72A8,8,0,0,1,40,72H216a8,8,0,0,1,7.52,10.73l-26.18,72a8,8,0,0,1-7.52,5.27Z" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
</svg>
</icon>
<icon name="airplane-duotone">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
<rect width="256" height="256" fill="none"/>
<path d="M152,96l80,40v32l-80-16v32l16,16v32l-40-16L88,232V200l16-16V152L24,168V136l80-40V48a24,24,0,0,1,48,0Z" class="fill-duotone"/>
<path d="M152,96l80,40v32l-80-16v32l16,16v32l-40-16L88,232V200l16-16V152L24,168V136l80-40V48a24,24,0,0,1,48,0Z" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
</svg>
</icon>
</set>
</iconset>
And the associated .dis file: test-duotone.dis (1.3 KB)
Dark mode works almost as expected (the fill part is not exactly as I expected when opacity remains low).
But in light mode, color is not replaced: everything is black.
Dark mode:
![]()
Light mode:
![]()
When I try and create these icons in "standalone mode" (e.g. integrating the styles inside the svg node) and save them as single svgs, external viewers render what I was expecting:
But even pasting that same code into the button SVG editor does not render the same.
Is this a limitation coming from mixing the way styles are applied with Opus light/dark mode?
Or is there anything wrong in these results?
Would you see another way to achieve my goal (e.g. replacing currentColor with something defined at iconset level, without having to change every instance of currentColor + being able to apply some styles at top level).
Initial test done with 13.23.7
Seems to be the same with 13.23.9

