Using CSS with GTK

Hello,
I am developing an application using GTK+3.0 and half of my application is over and now i came to know about the css. But i am not sure how to use the css. I came through the gtk css documentation and i am not pretty sure about it. Some examples will be quite useful for me as i am beginner for Gtk with css. I can add css in my gtk but i dont know what to be written in the css file. SO the example css files alone will be handy.

Thanks for your time

1 Like

Hi Nishanth,

I am far from a CSS expert but here are a couple of CSS items that might be of interest.

The overview has some simple examples to get started.

https://developer.gnome.org/gtk3/stable/chap-css-overview.html

From an app developers perspective being able to name a widget and then reference the name in CSS is useful.

gtk_widget_set_name(widget, “my_widget_name”);

and then use it like

#my_widget_name {…

to set the properties that you want.

There are some CSS tutorials on the web but keep in mind the CSS might be a little different. If you see a “GtkButton” in the css tutorial you can replace it with “button” in versions of GTK after 3.20 and it should work fine.

If you want to test your program with the GTK theme Adwaita you can give the following a try.

GTK_THEME=Adwaita:dark ./keyboard1

Eric

thank you @cecashon,
Will try with this
Regards,
Nishanth

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