After years of using MacOS, I made a commitment this year to use, support, and develop for Linux on a regular basis.
Starting off with little knowledge of GTK, I progressed from "hello world" to working on my first app, but end user customization has always been close to my heart, so naturally I started looking at what it takes to bring a GTK desktop app from "stock system UI" to "developer and user themable".
All this to say, it could be my inexperience, but I'm finding that GTK seems to be very much "all or nothing" here. I can use all the default widgets and be 100% native, and I can "* { background-color: pink; }" my way into a blank canvas, but if I want to make custom controls that build on the user's system theme and whatever accessibility he/she has set up for him/herself, I'm on my own to make my best guesses.
There's no reliable way to determine whether the user is scaling text, using a dark or light theme, or something super high contrast for accessibility. I can try to query some built in widgets and make decisions from there, but I've found that quite flaky as well.
Moreover, even finding which classes to assign to widgets to "piggy back" off the common system colors when building my own widgets is a chore of hunting through themes like Adwaita to find the piece of the system widget I'm trying to utilize. It's not quite WPF "copy the entire widget's XML and re-implement it from scratch to customize it" bad, but for as powerful as the CSS support seems to be in GTK, it feels like there's a layer in between "full system UI" and "total rebrand" that's missing.
So for example you should be using this to use the user's foreground and background color:
color: @theme_fg_color;
background-color: @theme_bg_color;
You can use some modifier functions on those colors too to compute additional colors: https://developer.gnome.org/gtk4/stable/ch39s02.htmlI would suggest against trying to piggy back on built-in CSS styles; usually with the default widgets you want to favor composition over inheritance. But if you really need to you can use the GTK inspector to look at the styles on any given system widget, that should be a bit easier than grepping through the CSS.
Ironically, you used to be able to use system colors via CSS. Like it usually happens on the web, that feature was also removed because of security reasons - apparently it made it easier for scammers to render fake system popups.
The "dark or light" theme we have today is an absolute joke by comparison.
Many Gtk-engines were also much faster in terms of pure rendering speed.
Another issue as mentioned is that per-control CSS skinning breaks easily with custom themes. Instead of using system colors devs often hard-code a custom look.
Finally, some programs go for a fully custom theme that doesn't even work properly without. Darktable is one example. Darktable looks cool, but a long time I had a hard time reading it's controls since it didn't respect system's font sizes nor it allowed to change it. The contrast was poor. It now comes with several themes, but nothing matches my system theme, which is more accessible.
As much as I love darktable, I'd skip the custom UI any day.