Ui template style classes

Hi, I am trying to get a background color of ui text node change dynamically.

<style>
.nr-dashboard-widget-123_Test.Happy {
background-color: #ff0000; /* Change to the color you desire */
}
.nr-dashboard-widget-123_Test.Sad {
background-color: #0000ff; /* Change to the color you desire */
}
</style>

and change the colors by sending

msg.className in the msgs.

The current approach requires knowing the label name when defining the classes.

I want to ask if there is a better way.

When I inspect the page the ".nr-dashboard-widget-" is always added at the begging but couple tutorials i found online do not have that. Why is that.

If I have same label name for 2 text nodes but different classes i wish to use is it not problematic?

Kind Regards