Back to column formats
Column formattingSharePoint Online

Display icons by repeating

This sample demonstrates the use of the padStart and split operators to repeatedly display icons for the number of values in the number column.

Display icons by repeating 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": "div",
      "style": {
        "font-size": "15px",
        "margin": "5px 0px",
        "display": "flex",
        "flex-direction": "row",
        "align-items": "center"
      },
      "children": [
        {
          "elmType": "div",
          "txtContent": "@currentField",
          "style": {
            "min-width": "30px",
            "text-align": "center"
          }
        },
        {
          "elmType": "div",
          "style": {
            "display": "flex",
            "flex-direction": "row",
            "flex-wrap": "wrap",
            "visibility": "=if(floor(@currentField)<1,'hidden','visible')"
          },
          "children": [
            {
              "elmType": "div",
              "forEach": "iterator in split(padStart('',floor(@currentField)-1,'^'),'^')",
              "style": {
                "margin": "3px"
              },
              "attributes": {
                "iconName": "Contact"
              }
            }
          ]
        }
      ]
    }
  ]
}
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/1/children/0/forEach must match pattern "^[^\]\$@\. ]+ in (\@currentField|\[\$.+\])$"

From the contributor

How to use this sample

Summary

This sample demonstrates the use of the padStart and split operators to repeatedly display icons for the number of values in the number column.

screenshot of the sample

It also uses Fluent UI Icons, and by changing the iconName property, the icons to be displayed can be changed.

screenshot of the icon sample

View requirements

This format can be applied to a Number column.

Sample

Solution Author(s)
number-icon-repeat.json Tetsuya Kawahara
number-icon-repeat-with-number.json Tetsuya Kawahara

Version history

Version Date Comments
1.0 January 14, 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.