Back to view formats
View formattingSharePoint Online

Display a User's Photo in Group Header

This is a sample of customizing the group header when grouping by user column. Display the user's picture as well as the user's name in the group header.

Display a User's Photo in Group Header 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",
        "width": "100%",
        "overflow": "hidden"
      },
      "children": [
        {
          "elmType": "div",
          "children": [
            {
              "elmType": "span",
              "txtContent": "= @group.columnDisplayName + ':'"
            }
          ]
        },
        {
          "elmType": "div",
          "attributes": {
            "class": "ms-bgColor-themeLighter ms-fontColor-neutralSecondary"
          },
          "style": {
            "display": "inline-flex",
            "align-items": "center",
            "height": "32px",
            "overflow": "hidden",
            "border-radius": "19px",
            "padding-right": "8px",
            "margin": "2px"
          },
          "children": [
            {
              "elmType": "img",
              "attributes": {
                "src": "=getUserImage(@group.fieldData.email,'s')",
                "title": "@group.fieldData.title"
              },
              "style": {
                "width": "32px",
                "height": "32px",
                "display": "block",
                "border-radius": "50%"
              }
            },
            {
              "elmType": "div",
              "txtContent": "@group.fieldData.title",
              "attributes": {
                "title": "@group.fieldData.title",
                "class": "ms-fontWeight-bold"
              },
              "style": {
                "padding-left": "5px",
                "white-space": "nowrap"
              }
            },
            {
              "elmType": "div",
              "style": {
                "padding-left": "5px",
                "padding-right": "5px"
              },
              "attributes": {
                "class": "ms-fontWeight-bold"
              },
              "txtContent": "= '(' + @group.count + ')'"
            }
          ]
        }
      ]
    }
  }
}

From the contributor

How to use this sample

Summary

This is a sample of customizing the group header when grouping by user column. Display the user's picture as well as the user's name in the group header.

screenshot of the sample

This format only affects the group header, the Assign column in the screenshot above is using out of the box display.

View requirements

Group by user column and display that user column in the view.

Sample

Solution Author(s)
group-header-user-picture.json Tetsuya Kawahara

Version history

Version Date Comments
1.0 April 3, 2021 Initial release
1.1 October 16, 2024 Changed to use getUserImage operator to get user's picture

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.