Adding Header To SharePoint List Form

Introduction

 
This is continuation of the article series, customizing SharePoint list forms using JSON which contains following
In this article, we will look into how to add header element to the form. This is continuation from article series Customizing List Forms Using JSON. For the simplicity we are adding a logo to header. You can do Visual Indicators, Color Ribbon and much more. Please refer to PnP samples in the references section.
 

Adding Header

 
Step 1
 
Click on new and select ‘Configure layout’
 
Adding Header To SharePoint List Form
 
Step 2
 
Make sure in the Format section. Apply formatting to is selected as ‘Header’.
 
Adding Header To SharePoint List Form
 
Step 3
 
In the JSON formatting box, apply the below JSON code to add information to header section. In here we are trying to add a logo in header.
 
Note
Make sure to chage the “src” to relative url to your company logo
  1. {  
  2.     "debugmode""true",  
  3.     "elmType""div",  
  4.     "attributes": {  
  5.         "class""ms-bgColor-white"  
  6.     },  
  7.     "style": {  
  8.         "width""99%",  
  9.         "border-top-width""0px",  
  10.         "border-bottom-width""1px",  
  11.         "border-left-width""0px",  
  12.         "border-right-width""0px",  
  13.         "border-style""solid",  
  14.         "margin-bottom""16px"  
  15.     },  
  16.     "children": [  
  17.         {  
  18.             "elmType""div",  
  19.             "style": {  
  20.                 "display""flex",  
  21.                 "box-sizing""border-box",  
  22.                 "align-items""center"  
  23.             },  
  24.             "children": [  
  25.                 {  
  26.                     "elmType""img",  
  27.                     "style": {  
  28.                         "width""150px"  
  29.                     },  
  30.                     "attributes": {  
  31.                         "src""RELATIVE URL TO LOGO"  
  32.                     }  
  33.                 }  
  34.             ]  
  35.         },  
  36.         {  
  37.             "elmType""div",  
  38.             "attributes": {  
  39.                 "class""ms-fontColor-blueMid ms-fontWeight-bold ms-fontSize-24"  
  40.             },  
  41.             "style": {  
  42.                 "box-sizing""border-box",  
  43.                 "width""100%",  
  44.                 "text-align""left",  
  45.                 "padding""21px 12px",  
  46.                 "overflow""hidden"  
  47.             },  
  48.             "children": [  
  49.                 {  
  50.                     "elmType""div",  
  51.                     "txtContent""=if ([$Title] == '', 'New Item', 'Item: ' + [$Title])"  
  52.                 }  
  53.             ]  
  54.         }  
  55.     ]  
  56. }  
Adding Header To SharePoint List Form
 
Step 4
 
Observe the logo after the formatting is saved successfully. You may want to refresh the browser
 
Adding Header To SharePoint List Form
 
Step 5
 
Troubleshoot if the logo is not appearing. if the logo did not appear. If it still fails, observe the JSON formatting is saved and you may want to investigate via developer tools for any formatting issues. You can copy paste the code from the git hub reference in reference section and modify the code according to your needs.
 

Conclusion

 
Thus in this article we have seen how to add header to your form. You can also add text or ribbon. please refer to microsoft docs on reference section. You can also watch the video series in reference section. 
 
References
  • https://pnp.github.io/sp-dev-list-formatting 
  • https://github.com/vayin/ListFormatting/blob/267daccd50986e2701241046aca59fc1d4cafe4f/Header_StaticBackGround_YourCompanyLogo.txt
  • https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/list-form-configuration
  • https://techcommunity.microsoft.com/t5/microsoft-365-pnp-blog/modern-sharepoint-list-formatting/ba-p/2128544
  • https://www.youtube.com/playlist?list=PLTyFh-qDKAiE7C_2lVNAPzgHXsBykG0Tf