What is the correct syntax for using several CSS classes from UI file?

I’ve already tried and failed several different ways of setting the GtkWidget's css-classes property from a UI file.

What is the correct syntax for the <property> contents if I wanted to add two classes simultaneously, like subtitle and warning?

I assume you read the GtkWidget as GtkBuildable documentation, which tells you that you should use the style element:

<object class="SomeWidget">
  <style>
    <class name="foo"/>
    <class name="bar"/>
    <class name="baz"/>
  </style>
</object>

The style element will add the CSS classes to your widget, in case there are additional classes added programmatically by the widget itself.

If you want to replace all CSS classes, or you know exactly when the widget will add CSS classes programmatically, then you can use the css-classes property as a newline-separated list of strings:

<object class="SomeWidget">
  <property name="css-classes">foo
bar
baz</property>
</object>

Personally, I recommend you use the style element.

That’s exactly the point. I already read the GtkWidget and the GtkBuild docs at least 3 times, but something always slips off because the UI file documentation is scattered through a lot of different places.

When my question came up, I was reading the css-classes property documentation because I got used to look for properties to set from the file, and that took a wrong turn…

Anyway, thank you for your help.