Back to view formats
View formattingSharePoint Online

Group Header Status Icon and Color

This is a sample of customizing the group header when grouping by a Status column. This format displays a different color and icon according to the Status.

Group Header Status Icon and Color formatting preview
Sample preview · View original image

Copy. Apply. Make it yours.

Get this format

1 definition

Review the requirements below, then paste this JSON into the matching formatting panel. Show me where.

Use your list's internal column names and replace any tenant-specific URLs or flow IDs. Formatting is presentation, not a way to secure data.

View formatting
Download JSON
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "groupProps": {
    "headerFormatter": {
      "elmType": "div",
      "style": {
        "flex-direction": "row"
      },
      "children": [
        {
          "elmType": "div",
          "attributes": {
            "class": "=if(@group.fieldData == 'Pending', 'sp-css-backgroundColor-BgCornflowerBlue', if(@group.fieldData == 'Approved', 'sp-css-backgroundColor-BgMintGreen',if(@group.fieldData == 'On Hold', 'sp-css-backgroundColor-BgGold',if(@group.fieldData == 'Rejected', 'sp-css-backgroundColor-BgCoral','sp-field-borderAllRegular sp-field-borderAllSolid sp-css-borderColor-neutralSecondary'))))"
          },
          "style": {
            "display": "inline-flex",
            "height": "25px",
            "border-radius": "15px",
            "padding-left": "8px",
            "padding-top": "5px"
          },
          "children": [
            {
              "elmType": "span",
              "attributes": {
                "iconName": "=if(@group.fieldData == 'On Hold', 'CirclePauseSolid', if(@group.fieldData == 'Approved', 'SkypeCircleCheck',if(@group.fieldData == 'Pending', 'ClipboardListQuestion',if(@group.fieldData == 'Rejected', 'Blocked','StatusCircleQuestionMark'))))"
              },
              "style": {
                "padding-right": "6px",
                "padding-top": "2px"
              }
            },
            {
              "elmType": "div",
              "style": {
                "display": "inline-flex",
                "padding-right": "9px"
              },
              "children": [
                {
                  "elmType": "div",
                  "style": {
                    "padding-left": "5px"
                  },
                  "attributes": {
                    "class": "ms-fontWeight-bold"
                  },
                  "txtContent": "=@group.count"
                },
                {
                  "elmType": "div",
                  "style": {
                    "padding-left": "5px"
                  },
                  "attributes": {
                    "class": "ms-fontWeight-normal"
                  },
                  "txtContent": "= if(@group.count!= 1,'Items are','Item is')"
                },
                {
                  "elmType": "div",
                  "txtContent": "=@group.fieldData",
                  "attributes": {
                    "title": "=@group.fieldData",
                    "class": "ms-fontWeight-bold"
                  },
                  "style": {
                    "padding-left": "5px"
                  }
                }
              ]
            }
          ]
        }
      ]
    }
  }
}

From the contributor

How to use this sample

Summary

This is a sample of customizing the group header when grouping by a Status column. This format displays a different color and icon according to the Status.

Also changes labeling according to being only one item or more:

  • 1 item is 'Status'
  • X items are 'Status'

screenshot of the sample

This format only affects the group header, the Status column in the screenshot above is using the out of the box pill formatting.

View requirements

Group by a Status Choice column and display that choice column in the view.

Choice values managed for the status choice column in this sample:

  • Pending
  • Approved
  • Rejected
  • On Hold

Sample

Solution Author(s)
group-header-status-icon-color.json Michel Mendes

Version history

Version Date Comments
1.0 October 26, 2021 Initial release

Disclaimer

THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.