Back to column formats
Column formattingSharePoint Online

Color Circles

This sample demonstrates displaying a circle of the color of the value of the choices.

Color Circles 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.

Column formatting
Download JSON
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "children": [
    {
      "elmType": "div",
      "style": {
        "display": "flex",
        "flex-direction": "row",
        "flex-wrap": "wrap",
        "margin": "5px 0px"
      },
      "children": [
        {
          "elmType": "div",
          "forEach": "_colorcircle in @currentField",
          "style": {
            "margin": "3px",
            "display": "flex",
            "flex-direction": "row",
            "align-items": "center"
          },
          "attributes": {
            "title": "[$_colorcircle]"
          },
          "children": [
            {
              "elmType": "div",
              "style": {
                "width": "24px",
                "height": "24px"
              },
              "children": [
                {
                  "elmType": "svg",
                  "style": {
                    "stroke": "gray",
                    "min-width": "100%",
                    "min-height": "100%"
                  },
                  "attributes": {
                    "viewBox": "0 0 200 200"
                  },
                  "children": [
                    {
                      "elmType": "path",
                      "forEach": "_color in split([$_colorcircle],'+')",
                      "style": {
                        "fill": "currentColor",
                        "color": "[$_color]"
                      },
                      "attributes": {
                        "d": "=if(length(split([$_colorcircle],'+'))==1,'M200,100 A100,100 0 1,0 0,100 A100,100 0 1,0 200,100','M100,100 L'+(100+100*cos((360*loopIndex('_color')/length(split([$_colorcircle],'+'))-90)*(3.14159265/180)))+','+(100+100*sin((360*loopIndex('_color')/length(split([$_colorcircle],'+'))-90)*(3.14159265/180)))+' A100,100 0 '+if(1/length(split([$_colorcircle],'+'))<=0.5,'0','1')+',1 '+(100+100*cos((360*(loopIndex('_color')+1)/length(split([$_colorcircle],'+'))-90)*(3.14159265/180)))+','+(100+100*sin((360*(loopIndex('_color')+1)/length(split([$_colorcircle],'+'))-90)*(3.14159265/180)))+' Z')"
                      }
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}
Schema compatibility review notes

This historical definition differs from the pinned Microsoft schema. This may indicate an unsupported pattern or a schema limitation. Check the original requirements and test in your tenant before use.

  • /children/0/children/0/children/0/children/0/children/0/forEach must match pattern "^[^\]\$@\. ]+ in (\@currentField|\[\$.+\])$"

From the contributor

How to use this sample

Summary

This sample demonstrates displaying circles of the color of the values of the choices. The circles are shown using SVG to display two-tone colors and various color schemes.

screenshot of the sample

The value of the choices must be set to the HTML color code or HTML color name. (e.g. Red, #038387) Also, to set a two-tone or higher color scheme, a + must be set between colors. (e.g. Orange+Purple, Blue+Green+Gray)

screenshot of the edit column

View requirements

  • This format can be applied to a Multi-Select Choice column

Sample

Solution Author(s)
multi-choice-color-circles.json Tetsuya Kawahara

Version history

Version Date Comments
1.0 July 17, 2023 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.