Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

CSS Classes and Rules

tomasscerba
Mega Sage

Hi All,

 

does anyone figure it out how to apply CSS rules in UI Builder and what they are for? ServiceNow Docs regarding this topic is a joke.

 

Create custom style classes and rules • Australia Build or modify applications • Docs | ServiceNow

 

Has anyone ever figured it out how to for example apply some CSS on :hover?

 

Any help would be appreciated.

 

Thanks.

7 REPLIES 7

So is this just a way of organizing classes that we intend to apply conditionally vs ones we don't? I did something very similar, but with "Classes" rather than "Rules". I suspect this would work exactly the same either way.

@Fernnn ,

yes its weired. For me classes are redundant there as components already have css in then co will just add class on top of class. That’s why I used rules instead of classes to apply new styling.

This is the way I did it:
IF(
@item.value.hasOverride, "diagonal-stripe-background", "") (no JS required, just regular data binding)
Fernnn_0-1776260390497.png

Looks like with rules, you have to specify the ".", implying that you can also define ids and maybe other things. I tried to test using both but my dev instance is not behaving well. It may be time for a new one.