cssgtk3

Setting Cursor Color in GTK 3 (since 3.16)


In a gtk3 program, I can use CSS to set e.g. white text on black background. But the text cursor (I-beam) remains black, unusable on dark background.

Only current info that I could find among all the outdated docs says:

override_cursor(cursor, secondary_cursor)

Deprecated since version 3.16: This function is not useful in the context of CSS-based rendering. If you wish to change the color used to render the primary and secondary cursors you should use a custom CSS style, through an application-specific Gtk.StyleProvider and a CSS style class.

Setting cursor-color with CSS doesn't work, I get

The style property GtkWidget:cursor-color is deprecated

How can I set cursor color in GTK 3 nowadays?


Solution

  • Use caret-color in your GTK CSS to change the focused cursor color in GTK apps (like Zim).

    #zim-pageview* {
      background-color: #584624;
      color : #FFFFFF;
      caret-color: white;
    }