Share via

Sharepoint Column Formatting Text Colour

needhelpwithJSON 41 Reputation points
2022-01-18T13:27:24.98+00:00

Dear all,

Please can someone advise me on how and where to add colour code to this JSON script.

(1) For red background Can someone help me with Text colour
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color": "=if(@currentField <=@now ,'#f53337',if(@currentField <=(@now +7776000000) ,'#96882b','#458b50'))"
}
}

(2) Same as number 1
{
"$schema":"https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType":"div",
"txtContent":"@currentField",
"style":{
"background-color":"=if((@currentField, if(@currentField <@now , '#f53337', if(@currentField <=@now +7776000000, '#96882b', '#458b50')),'')"
}
}

any help is greatly appreciated.

Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft 365 and Office | SharePoint Server | Development
0 comments No comments

Answer accepted by question author

Navas Shereef 141 Reputation points
2022-01-18T17:53:19.493+00:00

Hey,

You can add text color before or after background-color inside style tag. Hope this helps!

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color": "=if(@currentField <=@now ,'#f53337',if(@currentField <=(@now +7776000000) ,'#96882b','#458b50'))",
"color":"white"
}
}

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.