Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Using CSS variables in Field Styles.

Nikolay Mikheev
Tera Contributor

I want to use color values from the themes for styling fields (Field Styles) in ServiceNow.The main idea of this - to enable users to have personal (themed) settings for coloring priority in tasks.

Here is a questions:

 How to use these variables from Field style? At the moment I couldn't use any CSS variables in styles directly:

    background-color:$search-text-color
    
Any ideas?

Regards, Nikolay.

6 REPLIES 6

I don't need to change themes, I need to apply themed color to data fields in list.  Themes in SN apply only for User Interface, not to the data fields in lists. I need to apply colors from themes to data fields according to certain rules. I know how to set the rules - the field "Condition" allows using javascript. But I can`t assign colour in field "Style" because I don`t have access to colour variables from user theme.

 

Oleg
Mega Sage

It seems to me that correct referencing of CSS variables would be ${$varname} instead of $varname used in Service Portal.

You can search in style sheets found under Content Management > Design > Style Sheets for "${$" and will find some usage of variables defined in System UI > Themes.