0

How to change the background color of a list to red with JSON?

This is what I have:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "additionalRowClass": "=if(@rowIndex % 2 == 0,'ms-bgColor-communicationTint40 ms-bgColor-communicationTint30--hover','ms-bgColor-white')"
}

But I need also the background color of the list to red. How can I do that?

2 Answers 2

1

Unfortunately, you cannot change the background color "whole" list using SharePoint JSON view formatting.

You can only change the background color of individual rows (items) in the SharePoint list.

You can use JSON like below for changing the background color of "rows" to red:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "additionalRowClass": "=if(@rowIndex % 2 == 0,'ms-bgColor-red ms-bgColor-redDark--hover','ms-bgColor-white')"
}

Output:

enter image description here

1
  • Additional Info: Microsoft is releasing a new feature for site pages using which you can change the background color of "section" on the page like: i.sstatic.net/5hVOl.png. However, it does not change the color of list itself. If you are find with this, you can create a site page, add your list on page using List web part and change the background options for the section where list is added. Commented Mar 29 at 6:06
0

Using the following code to change the background color of a list to red :

  "elmType": "div",
       "style": {
          "background-color": "#ff0000"
       }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.