4 ms·
For whatever reason this is not well documented, but all the theme's colors are available with a special syntax in the CSS: https://gitlab.gnome.org/GNOME/gtk/-
by cycloptic 6y ago
For whatever reason this is not well documented, but all the theme's colors are available with a special syntax in the CSS: https://gitlab.gnome.org/GNOME/gtk/-/blob/master/gtk/theme/Adwaita/_colors-public.scss https://gitlab.gnome.org/GNOME/gtk/-/blob/master/gtk/theme/A...
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.html https://developer.gnome.org/gtk4/stable/ch39s02.html
I 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.
- kiawe_fire 6y agoThanks for the pointers, this is very helpful!