How to apply CSS class to Gio Icon in Gtk Entry?

Seems Icon is not widget, so can’t apply CSS class to it.

added with Entry.set_icon_from_gicon - any option to colorize?

GIcon is not a widget, and thus has no style; it’s just an interface for objects representing an icon asset.

You style the entry widget: GtkEntry: CSS nodes.

1 Like

Thanks, have implemented with first_child extraction

entry.first_child().unwrap().add_css_class("success")

This is not how you do things. There’s no guarantee that the first child is going to be the primary icon.

Add a class to the entry, then define the CSS selector for that:

entry.success image.left {
  ...
}
1 Like

Sure, I understand the risk of using child extractor, just trying to apply the class without external CSS rule connecting (as not using custom style provider yet)

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