SharePoint modern list view customization example

In this SharePoint customization tutorial, we will discuss how to customize the SharePoint modern list view using JSON.

As we know in the year 2016, SharePoint online team released Modern List and Library experience in both SharePoint On-Premise and online. So now a day business recommends this feature for more benefits.

I am not using JSLink to customize our modern list rather than, I am going forward to use JSON for an excellent user interface.

If we go in detail, there are many good features added in both modern lists and libraries but here I am using those called List View Customization.

SharePoint modern list view customization example

Here, I have taken a laptop list and we will see how by using the SharePoint Online list view customization using JSON, we can change the list view.

Step 1: I have created a SharePoint Online List called Laptop List and it contains the following column name.

  • Title – Single Line Text
  • Model- Single Line Text.
  • Processor– Single Line Text
  • RAM: Single Line Text
  • Hard Disk: Single Line Text
  • Screen Size: Singe Line Text
  • Battery : Single Line Text
  • Rating : Number
  • Photo: Hyperlink
sharepoint list view customization

Step 2: Next click on All Items and click on Format View to implement our customization code.

sharepoint online modern list view

Step 3: Next copy the below code and paste it inside code editor and click on Save.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
  "hideSelection": true,
  "hideColumnHeader": true,
  "rowFormatter": {
    "elmType": "div",
    "_comment_": "Laptop Photo DIV",
    "attributes": {
      "class": "ms-bgColor-greenLight"
    },
	"style": {
      "display": "flex",
      "flex-wrap": "wrap",
      "align-items": "stretch",
      "flex-direction": "row",
      "padding": "20px",
      "margin-bottom": "16px",
      "max-width": "850px",
      "border-radius": "8px"
    },
	"children": [
  {
        "elmType": "div",
        "__comment": "DIV L1",
        "style": {
          "flex-grow": "1",
          "display": "flex",
          "flex-direction": "column",
          "flex-wrap": "nowrap",
          "align-items": "stretch",
          "max-width": "260px"
        },
		"children": [
          {
            "elmType": "img",
            "style": {
              "width": "260px",
              "height": "160px"
            },
            "attributes": {
              "src": "[$Photo]"
            }
          }
        ]
		},
		{
        "elmType": "div",
        "__comment": "DIV L2",
        "style": {
          "flex-grow": "1",
          "display": "flex",
          "flex-direction": "column",
          "flex-wrap": "nowrap",
          "align-items": "center",
          "max-width": "360px",
          "min-width": "205px"
        },
		"children": [
          {
            "elmType": "span",
            "txtContent":"='Brand : ' + [$Title]",
            "style": {
              "display": "block"
            },
            "attributes": {
              "class": "ms-fontSize-l ms-fontWeight-semibold ms-fontColor-neutralPrimary"
            }
			
          },
		  {
            "elmType": "span",
            "txtContent": "Model",
            "style": {
              "display": "block",
              "padding-top": "20px"
            },
            "attributes": {
              "class": "ms-fontSize-l ms-fontWeight-semibold ms-fontColor-neutralPrimary"
            }
		  },
		  {
            "elmType": "span",
            "txtContent": "[$Model]"
          },
		  {
            "elmType": "span",
            "txtContent": "='Processor : ' + [$Processor]",
            "style": {
              "display": "block",
              "padding-top": "20px"
            },
			"attributes": {
              "class": "ms-fontSize-l ms-fontWeight-semibold ms-fontColor-neutralPrimary"
            }
          }		  
		  ]		
		},
		
		{
        "elmType": "div",
        "__comment": "DIV L3",
        "style": {
          "flex-grow": "1",
          "display": "flex",
          "flex-direction": "column",
          "align-items": "center",
          "margin-top": "10px",
          "max-width": "310px",
          "min-width": "155px"
        },
        "children": [
          {
            "elmType": "div",
            "__comment": "HardWwareDIV",
            "style": {
              "display": "block",
              "font-size": "15px",
              "font-weight": "bold"
            },
			"children": [
              {
                "elmType": "span",
                "txtContent": "[$RAM]",
                "style": {
                  "padding-right": "5px"
                }
              }
		]
			
			
		},
		{
            "elmType": "span",
            "txtContent": "Price",
            "style": {
              "display": "block",
              "padding-top": "20px"
            },
            "attributes": {
              "class": "ms-fontSize-l ms-fontWeight-semibold ms-fontColor-neutralPrimary"
            }
          },
		  {
            "elmType": "span",
            "txtContent": "=[$Price]",
            "style": {
              "display": "block"
            }
          },
		  
		  {
            "elmType": "span",
            "txtContent": "Rating",
            "style": {
              "display": "block",
              "padding-top": "20px"
            },
            "attributes": {
              "class": "ms-fontSize-l ms-fontWeight-semibold ms-fontColor-neutralPrimary"
            }
          },
		  {
            "elmType": "span",
            "txtContent": "=[$Rating]",
            "style": {
                  "padding-right": "5px"
                }
          },
		  {
                "elmType": "span",
                "attributes": {
                  "iconName": "FavoriteStarFill",
                  "class": "ms-fontColor-themePrimary"
                }
              }		  
		]
		}
		]
	}
	}

Step 4: Once I click on the Save button, the SharePoint List view got changed to different views which same as the below screenshot.

sharepoint modern list view customization

This is all about customization of List View in SharePoint Modern List.

You may like following SharePoint tutorials:

Reference: for ms-bgcolor change , you can follow the below URL

  • https://sharepoint-json-formatter.herokuapp.com/
  • https://docs.microsoft.com/en-us/sharepoint/dev/design/themes-colors
  • https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting
  • https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/view-formatting

In this SharePoint tutorial, we learned how by using the SharePoint Online list view customization using JSON, we can change the list view.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>