Back to column formats
Column formattingSharePoint 2019SharePoint Online

Highlight the Current User

This sample uses the @me keyword to check if the person field is the current user and shows that person using a different color and weight. This is a dynamic check that will always highlight the user using the list (not the creater of the format). This template could easily be extended to apply different/additional styles or icons as desired by simply copying the same expression logic for other fields.

Highlight the Current User formatting preview
Sample preview · View original image

Copy. Apply. Make it yours.

Get this format

2 definitions

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.

Column formatting
Download JSON
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField.title",
  "attributes": {
    "class": "=if(@me == @currentField.email, 'ms-fontColor-themePrimary ms-fontWeight-semibold', '')"
  }
}

From the contributor

How to use this sample

Summary

This sample uses the @me keyword to check if the person field is the current user and shows that person using a different color and weight. This is a dynamic check that will always highlight the user using the list (not the creater of the format). This template could easily be extended to apply different/additional styles or icons as desired by simply copying the same expression logic for other fields.

The Office UI Fabric theme color classes and a font weight class are used to ensure the format looks good across themes (including custom themes).

screenshot of the sample

View requirements

  • This format can be applied to a Person column

Sample

Solution Author(s)
person-currentuser.json Chris Kent

Version history

Version Date Comments
1.0 March 20, 2018 Initial release
1.1 August 18, 2018 Using theme classes and switched to Excel-style expressions

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.


Additional notes

This sample is also covered in the main documentation around Column Formatting.

A similar template is also included in the Column Formatter webpart.

An additional version using Abstract Tree Syntax (AST) is also provided for environments where the Excel-style expressions are not supported.

A similar sample is available for use with multi-select person fields: multi-person-currentuser