Search code examples
cssthemesgradientgtk4

Gradient BGs in GTK4


I have been using this code for gradients in GTK3 CSS:

background-image: -gtk-gradient (
radial,
center center, 0,
center center, 1,
from (alpha(shade(@bg_color, 1.05), 0.925)),
to (alpha(shade(@bg_color, 0.85), 0.925)));

but in GTK4, with this code the BG doesn't render, and in terminal it says:

(gtk4-widget-factory:4546): Gtk-WARNING **: 13:30:10.541: Theme parser error: gtk.css:335:19-32: Not a valid image

I also tried the original CSS gradient code (radial-gradient), with no success.

So how do I make gradients on GTK4 CSS?


Solution

  • I don't know the syntax in detail, I usually just reproduce examples that I already know, but here's an example that works.

    background-image: linear-gradient(
         to bottom right,
         #fff 49.99%,
         #202020 50.01%
       );