We can configure the SharePoint modern site list form using JSON formatting, which has the following use cases:
- If you want to implement multiple column forms rather than existing single column look and feel
- If you want to hide and show field/column-based forms in a simple and easy way
- If you don’t have Power App license but still want to change some look and feel of list forms
- If you want to group the fields/columns in the list form
Steps to use JSON formatting to change the form look and feel follows the below steps:
- Open the New form of list
- See the form is showing only one column view
- Click on the highlighted icon and choose the below option
- The below screen will appear, It will shows a dropdown with three options namely
- Copy the JSON and paste in the field for header
- {
- "debugMode": true,
- "elmType": "div",
- "attributes": {
- "class": "ms-borderColor-neutralTertiary"
- },
- "style": {
- "width": "99%",
- "border-top-width": "0px",
- "border-bottom-width": "1px",
- "border-left-width": "0px",
- "border-right-width": "0px",
- "border-style": "solid",
- "margin-bottom": "16px",
- "background-color": "#026d70"
- },
- "children": [{
- "elmType": "div",
- "style": {
- "display": "flex",
- "box-sizing": "border-box",
- "align-items": "center"
- },
- "children": [{
- "elmType": "div",
- "attributes": {
- "iconName": "Group",
- -Use icon as per your requirement "class": "ms-fontSize-42 ms-fontWeight-regular ms-fontColor-white",
- "title": "Details"
- },
- "style": {
- "flex": "none",
- "padding": "0px",
- "padding-left": "5px",
- "height": "36px"
- }
- }]
- }, {
- "elmType": "div",
- "attributes": {
- "class": "ms-fontColor-neutralSecondary ms-fontWeight-bold ms-fontSize-24"
- },
- "style": {
- "box-sizing": "border-box",
- "width": "100%",
- "text-align": "left",
- "padding": "21px 12px",
- "overflow": "hidden",
- "color": "white"
- },
- "children": [{
- "elmType": "div",
- "txtContent": "New Form" - This is the Form Title
- }]
- }]
- }
The above JSON is self-explanatory, which has three div.’s, first div is for main container div for header and next two for below…
Click on preview button to see the applied JSON configuration to header.
- For Body, copy and paste the below JSON, choose Body from dropdown first
- {
- "sections": [{
- "displayname": "Group name 1",
- "fields": ["Field Display name1", "Field Display name2"]
- }, {
- "displayname": "Group name 2",
- "fields": ["Field Display name1", "Field Display name2"]
- }]
- }
Here in the above JSON, Section is used to divide the fields in multi column views. Use the column display name to put that column section if any field not mention the section then that field/column will automatically display in the last section.
You can see the JSON is self-explanatory so you can add any number of sections here in the JSON.
- For Footer copy and pasting below JSON, buttons will not be associated with any part; i.e. it is not associated with Header, Body or Footer section.
- {
- "debugMode": true,
- "elmType": "div",
- "style": {
- "width": "100%",
- "text-align": "left",
- "overflow": "hidden",
- "border-top-width": "1px"
- },
- "children": [{
- "elmType": "div",
- "style": {
- "width": "100%",
- "margin-top": "20px",
- "margin-bottom": "10px",
- "height": "4px",
- "background-color": "#026d70"
- }
- }]
- }
The above JSON is just to add some border margin below the body, and you can refer the header JSON to add div children in this section if you want. Just complete all these steps and your list form will look better than the default list form, just click on Save button as highlighted in the below screen.
This formatting will apply to all three forms of SharePoint list form.
For more information please visit the Microsoft site.