Since the widget toolkit is GTK3 theming is done with CSS.
:::caution[GTK is not the web] While most features are implemented in GTK, you can't assume anything that works on the web will work with GTK. Refer to the GTK docs to see what is available. :::
So far every widget you made used your default GTK3 theme. To make them more
custom, you can apply stylesheets to them, which are either imported css files
or inline css applied with the css property.
// config.js
App.config({
// this style attribute takes a full path to a css file
style: "/home/username/.config/ags/style.css",
// or relative to config.js
style: "./style.css",
});
Widget.Label({
css: "color: blue; padding: 1em;",
label: "hello",
});
App.applyCss will apply over other stylesheets applied before. You can reset
stylesheets with App.resetCss
App.applyCss("/path/to/file.css");
App.applyCss(`
window {
background-color: transparent;
}
`);
App.resetCss(); // reset if need
If you are not sure about the widget hierarchy or any CSS selector, you can use the GTK inspector
# to bring up the inspector run
ags --inspector
// config.js
// main scss file
const scss = `${App.configDir}/style.scss`;
// target css file
const css = `/tmp/my-style.css`;
// make sure sassc is installed on your system
Utils.exec(`sassc ${scss} ${css}`);
App.config({
style: css,
windows: [/* windows */],
});
Utils.monitorFile(
// directory that contains the scss files
`${App.configDir}/style`,
// reload function
function () {
// main scss file
const scss = `${App.configDir}/style.scss`;
// target css file
const css = `/tmp/my-style.css`;
// compile, reset, apply
Utils.exec(`sassc ${scss} ${css}`);
App.resetCss();
App.applyCss(css);
},
);