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

Deepak Ingale1
Mega Sage

Hi,

 

Below link will help you to configure field styles, it has all the examples to get started and understand the concept

https://docs.servicenow.com/bundle/london-platform-administration/page/administer/navigation-and-ui/...

 

Note: Please mark reply as correct if it has answered your question or helpful if it has assisted you with respect to your question

Nikolay Mikheev
Tera Contributor

Hi,

I read it many times. There is not a word about how to set a color (for example, background or font) as value from user theme, like $navpage-header-color or $navpage-button-color.

I've tried 

background-color: $navpage-header-color

background-color: css.$navpage-header-color

background-color: "${gs.getProperty('css.base.color','#6699CC')}";

background-color:javascript:${gs.getProperty('css.base.color','#6699CC')}

but none of the options work.

Regards, Nikolay.

 

I'm don't think this is supported, never considered using it this way.

So many styles are overridden by the system in UI16 that I personally don't even bother with field styles anymore.


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

Did you try below link to create your own themes ?

 

https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/administer/navigation_and_ui/task...

 

I know it was working before UI16, I have not tried it with UI16 though, you may give it a try