How to create a birthday view using SharePoint Online modern list view customization

In this SharePoint customization tutorial, we will discuss how to create a birthday view using SharePoint Online modern list view customization using JSON.

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

I am not using ant 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.

Create a birthday view using SharePoint Online modern list view customization

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

  • Title – Single Line Text
  • Company – Single Line Text
  • E-Mail – Single Line Text
  • Department – Single Line Text
  • Designation – Single Line Text
  • Photo – photo
  • Birthday – Date
  • DOM – Single Line Text
create a birthday view using SharePoint Online modern list view customization

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

create a birthday view sharepoint online

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,
  "hideListHeader": true,
  "rowFormatter": {
    "elmType": "div",
    "style": {
      "display": "flex",
      "flex-wrap": "wrap",
      "align-items": "stretch",
      "padding": "8px",
      "margin-bottom": "25px",
      "max-width": "420px",
      "border-radius": "8px",
      "box-shadow": "4px 4px 8px lightblue"
    },
    "attributes": {
      "class": "ms-bgColor-themePrimary ms-fontColor-white"
    },
    "children": [
      {
        "elmType": "div",
        "style": {
          "flex-grow": "1",
          "display": "flex",
          "flex-wrap": "wrap",
          "align-items": "stretch",
          "max-width": "310px"
        },
        "children": [
          {
            "elmType": "div",
            "style": {
              "flex": "none"
            },
            "children": [
              {
                "elmType": "div",
                "style": {
                  "height": "100px",
                  "overflow": "hidden",
                  "border-radius": "5%",
                  "margin-right": "8px"
                },
                "children": [
                  {
                    "elmType": "span",
                    "txtContent": "[$Title]",
                    "style": {
                      "display": "block"
                    },
                    "attributes": {
                      "class": "ms-fontSize-l ms-fontWeight-semibold ms-fontColor-white"
                    }
                  },
                  {
                    "elmType": "span",
                    "txtContent": "[$Company]",
                    "style": {
                      "display": "=if([$Company] == '', 'none', 'block')"
                    },
                    "attributes": {
                      "class": "ms-fontSize-m ms-fontWeight-regular ms-fontColor-white"
                    }
                  },
                  {
                    "elmType": "span",
                    "txtContent": "[$Department]",
                    "style": {
                      "display": "=if([$Department] == '', 'none', 'block')"
                    },
                    "attributes": {
                      "class": "ms-fontSize-m ms-fontWeight-regular ms-fontColor-white"
                    }
                  },
                  {
                    "elmType": "span",
                    "txtContent": "[$Designation]",
                    "style": {
                      "display": "=if([$Designation] == '', 'none', 'block')"
                    },
                    "attributes": {
                      "class": "ms-fontSize-m ms-fontWeight-regular ms-fontColor-white"
                    }
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "elmType": "div",
        "style": {
          "display": "flex",
          "flex-direction": "column",
          "max-width": "310px",
          "min-width": "95px"
        },
        "children": [
          {
            "elmType": "div",
            "style": {
              "flex-grow": "1"
            },
            "children": [
              {
                "elmType": "span",
                "style": {
                  "display": "=if([$Birthday] <= @now,'block','none')"
                },
                "attributes": {
                  "iconName": "BirthdayCake"
                }
              },
              {
                "elmType": "span",
                "style": {
                  "display": "block"
                },
                "attributes": {
                  "class": "ms-fontWeight-semibold ms-fontSize-m"
                },
                "txtContent": "=if([$Birthday] <= @now,'Happy Birthday!', 'Next Birthday')"
              },
              {
                "elmType": "span",
                "style": {
                  "display": "=if([$Birthday] == '', 'none', 'block')",
                  "padding-left": "0px",
                  "font-size": "14px"
                },
                "txtContent": "[$DOM]",
                "attributes": {
                  "class": "ms-fontSize-s ms-fontWeight-regular ms-fontColor-white"
                }
              },
              {
                "elmType": "span",
                "style": {
                  "display": "=if([$Birthday] == '', 'block', 'none')",
                  "padding-left": "8px"
                },
                "txtContent": "No Birthday Entered",
                "attributes": {
                  "class": "ms-fontSize-s ms-fontWeight-semilight ms-fontColor-white"
                }
              }
            ]
          },
          {
            "elmType": "div",
            "style": {
              "flex": "none",
              "display": "flex",
              "flex-direction": "row-reverse",
              "flex-wrap": "nowrap"
            },
            "children": [
              {
                "elmType": "a",
                "style": {
                  "display": "=if([$EMail] == '', 'none', 'block')"
                },
                "attributes": {
                  "class": "ms-fontSize-xs ms-fontWeight-regular ms-fontColor-white ms-fontColor-white--hover",
                  "href": "='mailto:' + [$EMail] + '?subject=Happy Birthday!\r\n'"
                },
                "children": [
                  {
                    "elmType": "span",
                    "attributes": {
                      "iconName": "Mail"
                    }
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  }
}

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

SharePoint Online modern list view customization

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

You may like following tutorials:

Reference: for theme color change and generate the JSON format , you can follow the below URL

In this tutorial, we learned how to Create a birthday view using SharePoint Online modern list view customization using JSON.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

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

>