Back to column formats
Column formattingSharePoint 2019SharePoint Online

Traffic Light (Red-Yellow-Green) Status Indicator

This sample displays a traffic light style (Red-Yellow-Green) status indicator based on the value of a choice/text column (to use a lookup column, switch all occurrences of `@currentField` to `@currentField.lookupValue`).

Traffic Light (Red-Yellow-Green) Status Indicator 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",
  "children": [
    {
      "elmType": "span",
      "style": {
        "width": "14px",
        "height": "14px",
        "border-radius": "50%"
      },
      "attributes": {
        "class": "=if(@currentField == 'Green', 'ms-bgColor-green', if(@currentField == 'Yellow', 'ms-bgColor-yellow', if(@currentField == 'Red', 'ms-bgColor-red', '')))"
      }
    }
  ]
}

From the contributor

How to use this sample

Summary

This sample displays a traffic light style (Red-Yellow-Green) status indicator based on the value of a choice/text column (to use a lookup column, switch all occurrences of @currentField to @currentField.lookupValue).

screenshot of the sample

The text values for the column are expected to be Red, Yellow, or Green. Any other values won't be shown.

View requirements

  • This format can be applied to a text/choice column and expects the values to be Green, Yellow, Red, or anything else

Sample

Solution Author(s)
text-ryg-status-indicator.json Travis Lingenfelder

Version history

Version Date Comments
1.0 November 27, 2017 Initial release
1.1 March 22, 2018 Simplified logic
1.2 August 20, 2018 Updated to use Excel-style expressions and theme classes

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

For more information on using this custom formatting see the article SharePoint Modern List Traffic Light (Red-Yellow-Green) Status Indicator Column

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