There are new capabilities for symbolic icons introduced in the brand new gtk-4.22 (basically still svg, but with custom sugar on top) that allows to use accent as color name.
Looks like this for a <path>, here the stroke uses the accent color, with a fallback rgb(0,34,255) if not available:
Looking at the docs it seems that for symbolic icons only foreground/success/warning/error are supported in symbolic icons, not accent…
Does your icon have a -symbolic.svg suffix in its name? If yes try to just use .svg.
You may have to add fill='url(#gpa:foreground)' to the non-accent paths so they can get recolored.
Icons are currently in process of being replaced with a new system, that’s why everything is confusing. Accent support was itself added recently, and there is an old icon system and a new icon system (and a hybrid of old and new, aka old system but with stroke and accent support)
In theory there are 2 ways to do this, the old system supports class='accent' but it doesn’t seem to work in my testing. It did at some point, but ig it broke.
The new system (the gpa thing) works but you need nightly GTK (in theory 4.22 has it but it doesn’t seem to work in my testing, it’s possible that icon editor output just changed so much newer icons don’t work with 4.22 anymore) and it’s currently very new and experimental - doesn’t update when you change accent (I’ll file a bug), and icon editor crashes a lot. Overall I wouldn’t recommend using it just yet.
We’ll have a new icon system in libadwaita later, using gpa icons, and there will be an announcement detailing everything once that happens. Until then I’d just use older icons and override one of the other classes to be accent from CSS:
your-icon {
-gtk-icon-palette: error var(--accent-bg-color); /* or --accent-color, idk which one you want here */
}
Thank you very much for your feedback and my apologies for my late answer
Thanks a lot for the detailed explanation — that clears up exactly why my results were inconsistent. Knowing that there are effectively three systems in flight (old, new/gpa, and the old-with-stroke-and-accent hybrid) explains why class=‘accent’ worked in some of my tests and not in others.
I tried your CSS suggestion and I can confirm it works:
Repurposing one of the existing palette classes to carry the accent color does the job, and it works on stock GTK without any nightly build. Thanks for that.
That said, I’m going to hold off on rolling it out for now. My application ships a fairly large set of custom symbolic icons, and applying this approach means reworking all of them — each icon has to be authored so that the repurposed class (error, here) is the one carrying the shape I want accented. That’s a full pass over the icon set, and I’d rather not do it twice: once for the workaround now, and again for the real system when libadwaita lands its gpa-based icon support.
So my plan is to wait for the feature to mature — the libadwaita icon system and the announcement you mentioned — and do a single migration then. In the meantime I’ll keep using the older icons without accent, which is a cosmetic limitation I can live with.
Thanks again for taking the time, and I’ll be watching for the announcement.