Back to view formats
View formattingSharePoint Online

Christmas Tree

This sample draws a tree across rows in 3 different stages 'alt' as top, 'body' as tree and 'wood' as bottom. You can also include icons in the tree. The Title field will appear as a tooltip on the icons.

Christmas Tree formatting preview
Sample preview · View original animation

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.

View formatting
Download JSON
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
  "hideColumnHeader": "true",
  "hideSelection": true,
  "rowFormatter": {
    "elmType": "div",
    "style": {
      "position": "relative",
      "height": "=if([$Structure] == 'alt', '100px','50px')"
    },
    "children": [
      {
        "elmType": "div",
        "style": {
          "border-bottom": "=if([$Structure] == 'alt', '100px solid #'+[$color],'50px solid #'+[$color])",
          "border-left": "=if([$Structure] == 'alt', '70px solid transparent','25px solid transparent')",
          "border-right": "=if([$Structure] == 'alt', '80px solid transparent','25px solid transparent')",
          "height": "=if([$Structure] == 'alt', '0','0')",
          "width": "=if([$Structure] == 'alt', '0',if([$Structure] == 'wood', '50px','125px'))",
          "position": "=if([$Structure] == 'alt', 'absolute',if([$Structure] == 'wood','absolute','none'))",
          "left": "=if([$Structure] == 'alt', '12px', if([$Structure] == 'wood', '35px','0'))"
        }
      },
      {
        "elmType": "div",
        "style": {
          "font-size": "36px",
          "position": "absolute",
          "left": "=if([$Structure] == 'body', if([$GiftSide] == 'Left', '50px','80px'),if([$Structure] == 'alt', '65px','0px'))",
          "display": "=if([$Gift] == '', 'none', 'block')",
          "top": "=if([$Structure] == 'alt','-10px','')",
          "color": "=if([$Structure] == 'alt', '#ffb900', '')"
        },
        "attributes": {
          "iconName": "[$Gift]"
        },
        "customCardProps": {
          "formatter": {
            "elmType": "div",
            "txtContent": "=[$Title]",
            "style": {
              "font-size": "14px",
              "padding": "10px",
              "width": "160px",
              "color": "black",
              "background-color": "white"
            }
          },
          "openOnEvent": "click",
          "directionalHint": "rightCenter",
          "isBeakVisible": true,
          "beakStyle": {
            "backgroundColor": "white"
          }
        }
      }
    ]
  }
}
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.

  • /hideColumnHeader must be boolean

From the contributor

How to use this sample

Summary

This sample draws a tree across rows in 3 different stages "alt" as top, "body" as tree and "wood" as bottom. You can also include icons in the tree. The Title field will appear as a tooltip on the icons.

screenshot of the sample

Christmas Tree with Presents

Christmas Tree

View requirements

  • The format expect the following fields:
Field Type
Title Single line of text
Structure Single line of text - The tree is composed by the following structure: "alt" - Header of Tree (Triangle), "body" - body of tree (Trapezoid) and "wood" - Base of Tree (Smaller Trapezoid)
color Single line of text - (recommended colors for the tree 79a83f, 7cad40, c19c00. For the base of tree recommend color 7e5224). PS: no need to include #
Gift Single line of text - icons of gifts (samples GiftboxOpen, GiftCard, Giftbox, GiftBoxSolid and FavoriteStarFill for top of tree, )
GiftSide Single line of text - options "Left" or "Right"

Edit View requirements

  • Edit View where format will be included, access to "Sort" Area and select column "Structure" and check as ascending order, this option order tree correctly from top to bottom event when included new levels in the tree.

Sample

Solution Author(s)
christmas-tree.json André Lage

Version history

Version Date Comments
1.0 December 09, 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.