List of available style classes for GTK4

libadwaita has a dedicated page for style classes such as “.title-1” and “.dim-label”, but GTK 4 documentation doesn’t have this. Where can I find these style classes for GTK 4?

GTK4 does not really define style classes: that’s the job of a platform library, like libadwaita, or the job of application-specific styling.

2 Likes

Ok, thanks for explaining!

There are a few things however that could be documented. For example the fact that if someone implements a GtkOrientable widget this needs to have a horizontal or a vertical CSS class assigned; or the fact that there are cases in which children widget need to have a right, bottom, left or top CSS class assigned… I don’t know if these are currently documented, but I learned about them only by looking at the source code of GTK. Maybe a “CSS class list” page for GTK with all these cases would not be a bad idea…

Each widget type that relies on a class or a selector already has those selectors documented.

The documentation for GtkOrientable is missing a note about widgets implementing the interface adding the horizontal/vertical CSS classes, that’s true. Feel free to file an issue about it.

Additional CSS classes that are left to 3rd party code are not going to be documented; just because the default style in GTK4 uses them it doesn’t mean they are part of any stable API. If you want a stable style API, then you want to use libadwaita—that’s the whole point of that library.

Done :slight_smile:

I don’t know, sometimes by looking at GtkInspector I see that GTK does use CSS classes for specific purposes. So far the way I had understood the difference between GTK and libadwaita concerning CSS classes was that libadwaita uses “higher level” classes (things like card, suggested-action, etc.) while GTK used “lower level” classes, for expressing more primitive things (like horizontal, vertical, bottom, etc.). But if these will not be part of any GTK standard so be it.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.