how to just fill/highlight the text column using json on sharepoint online list

Jane 1 Reputation point
2022-05-30T21:28:51.153+00:00

I'm trying just highlight the text/number on a column in sharepoint online list, not color the whole field with "background-color", see example below.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color": "=if(@currentField <= 30, 'red', if(@currentField <= 60, 'yellow', ''))"
}
}
Which attribute can I use, just highlight the color on the number? Thanks for any help!

Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jinwei Li-MSFT 4,736 Reputation points Microsoft External Staff
    2022-05-31T07:35:25.143+00:00

    Hi @Jane ,

    Please try to use this:

    {  
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",  
      "elmType": "div",  
      "txtContent": "@currentField",  
      "style": {  
        "color": "=if(@currentField <= 30, 'red', if(@currentField <= 60, 'yellow', ''))"  
      }  
    }  
    

    Output:
    206983-image.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

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