Back to column formats
Column formattingSharePoint Online

Shaded Backgrounds

This sample demonstrates how to change the shade of the background color according to the value of the number column.

Shaded Backgrounds 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",
  "style": {
    "width": "100%",
    "height": "42px",
    "position": "relative",
    "white-space": "nowrap"
  },
  "children": [
    {
      "elmType": "div",
      "style": {
        "position": "abdolute",
        "width": "100%",
        "height": "100%",
        "opacity": "= ( (@currentField - (-100)) / (350 - (-100)) )",
        "background-color": "#FFBBFF"
      }
    },
    {
      "elmType": "div",
      "txtContent": "@currentField",
      "style": {
        "position": "absolute",
        "margin-left": "10px",
        "font-size": "18px"
      }
    }
  ]
}

From the contributor

How to use this sample

Summary

This sample demonstrates how to change the shade of the background color depending on the value of the number column. Also, in this sample, the background color is lightest at -100 and darkest at 350.

  • number-background-color-shading.json uses your site's theme color as the background color.
  • number-background-color-shading-custom-color.json uses the HTML color code as the background color, and in the sample, #FFBBFF is set.

screenshot of the sample

View requirements

This format can be applied to a Number column.

Sample

Solution Author(s)
number-background-color-shading.json Tetsuya Kawahara
number-background-color-shading-custom-color.json Tetsuya Kawahara

Version history

Version Date Comments
1.0 November 16, 2021 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.