this post was submitted on 31 Oct 2024
17 points (100.0% liked)
Rust
5989 readers
18 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Just use
label.add_css_class()
,label.remove_css_class()
orlabel.set_css_classes()
and make sure to properly load your CSS style sheets, this is usually done by including them as a resource alongside .ui files and icons. If you are using libadwaita, you can also use its predefined style classes.full example (requires nightly toolchain)
This is embarrassing, but when was it not?
I have to add a "." before the name of a
css
class, I must learn my tools.I mean, it is not embarrassing for you. In the browser, the CSS's "native platform", you add classes, via the JavaScript API, without the dot. It's not a stupid assumption.
To have to add the dot in the CSS class name seems a bit of an oversight in the gtkrs API.
(sorry for the late response, I have to get in the habit of checking my Lemmy account)
No, I get that - a stylesheet denotes a class by having a dot. A JavaScript API for adding a CSS class omits this redundancy.
I was saying that the author might not be wrong to want to avoid the redundancy in rust example as well (since it explicitly mentions CSS classes).
I think you understood their comment wrong. In your code (e.g.
label.add_css_class("green");
) you don't use a dot, but in the CSS stylesheet. It works the same as with HTML/JS/CSS.Well, that's CSS :D
Note that if you create a custom Widget class, you can set a CSS name, wich isn't a CSS class and doesn't use a leading dot.