SharePoint Online: reducing the height of the color background in list column

Vanessa 356 Reputation points
2023-09-18T15:31:51.4833333+00:00

How do I reduce the height of the background color of the items in the Color column?

Thanks

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "style": {
    "box-sizing": "border-box",
    "border-radius": "25px",
    "display": "flex",
    "justify-content": "center",
    "align-items": "center"
  },
  "attributes": {
    "class": {
      "operator": ":",
      "operands": [
        {
          "operator": "==",
          "operands": [
            "[$Color]",
            "Green"
          ]
        },
        "sp-css-backgroundColor-BgGreen sp-field-fontSizeSmall sp-css-color-WhiteText",
        {
          "operator": ":",
          "operands": [
            {
              "operator": "==",
              "operands": [
                "[$Color]",
                "Pink"
              ]
            },
            "sp-css-backgroundColor-BgCoral sp-field-fontSizeSmall sp-css-color-BlackText",
            {
              "operator": ":",
              "operands": [
                {
                  "operator": "==",
                  "operands": [
                    "[$Color]",
                    "Red"
                  ]
                },
                "sp-css-backgroundColor-BgRed sp-field-fontSizeSmall sp-css-color-WhiteText",
                {
                  "operator": ":",
                  "operands": [
                    {
                      "operator": "==",
                      "operands": [
                        "[$Color]",
                        "Maroon"
                      ]
                    },
                    "sp-css-backgroundColor-BgDarkRed sp-field-fontSizeSmall sp-css-color-WhiteText",
                    {
                      "operator": ":",
                      "operands": [
                        {
                          "operator": "==",
                          "operands": [
                            "[$Color]",
                            "Gray"
                          ]
                        },
                        "sp-css-backgroundColor-BgGray sp-field-fontSizeSmall sp-css-color-WhiteText",
                        {
                          "operator": ":",
                          "operands": [
                            {
                              "operator": "==",
                              "operands": [
                                "[$Color]",
                                "Orange"
                              ]
                            },
                            "sp-css-backgroundColor-BgOrange sp-field-fontSizeSmall sp-css-color-WhiteText",
                            {
                              "operator": ":",
                              "operands": [
                                {
                                  "operator": "==",
                                  "operands": [
                                    "[$Color]",
                                    "Lime"
                                  ]
                                },
                                "sp-css-backgroundColor-BgSage sp-css-borderColor-SageFont sp-field-fontSizeSmall sp-css-color-BlackText",
                                {
                                  "operator": ":",
                                  "operands": [
                                    {
                                      "operator": "==",
                                      "operands": [
                                        "[$Color]",
                                        "Purple"
                                      ]
                                    },
                                    "sp-css-backgroundColor-BgPurple sp-field-fontSizeSmall sp-css-color-WhiteText",
                                    {
                                      "operator": ":",
                                      "operands": [
                                        {
                                          "operator": "==",
                                          "operands": [
                                            "[$Color]",
                                            "Teal"
                                          ]
                                        },
                                        "sp-css-backgroundColor-BgTeal sp-field-fontSizeSmall sp-css-color-WhiteText",
                                        {
                                          "operator": ":",
                                          "operands": [
                                            {
                                              "operator": "==",
                                              "operands": [
                                                "[$Color]",
                                                "Gold"
                                              ]
                                            },
                                            "sp-css-backgroundColor-BgGold sp-field-fontSizeSmall sp-css-color-BlackText",
                                            {
                                              "operator": ":",
                                              "operands": [
                                                {
                                                  "operator": "==",
                                                  "operands": [
                                                    "[$Category]",
                                                    ""
                                                  ]
                                                },
                                                "sp-css-backgroundColor-BgLightBlue sp-css-color-LightBlueFont",
                                                ""
                                              ]
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  },
  "txtContent": "[$Color]"
}
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,567 questions
0 comments No comments
{count} votes

Accepted answer
  1. Emily Du-MSFT 45,746 Reputation points Microsoft Vendor
    2023-09-19T02:27:57.6266667+00:00

    Following JSON codes can change the height of the color background in list column.

    The line "min-height": "20px" controls the height, change the parament as you want.

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "style": {
        "box-sizing": "border-box",
        "border-radius": "25px",
        "min-height": "20px",
        "display": "flex",
        "justify-content": "center",
        "align-items": "center"
      },
      "attributes": {
        "class": {
          "operator": ":",
          "operands": [
            {
              "operator": "==",
              "operands": [
                "[$Color]",
                "Green"
              ]
            },
            "sp-css-backgroundColor-BgGreen sp-field-fontSizeSmall sp-css-color-WhiteText",
            {
              "operator": ":",
              "operands": [
                {
                  "operator": "==",
                  "operands": [
                    "[$Color]",
                    "Pink"
                  ]
                },
                "sp-css-backgroundColor-BgCoral sp-field-fontSizeSmall sp-css-color-BlackText",
                {
                  "operator": ":",
                  "operands": [
                    {
                      "operator": "==",
                      "operands": [
                        "[$Color]",
                        "Red"
                      ]
                    },
                    "sp-css-backgroundColor-BgRed sp-field-fontSizeSmall sp-css-color-WhiteText",
                    {
                      "operator": ":",
                      "operands": [
                        {
                          "operator": "==",
                          "operands": [
                            "[$Color]",
                            "Maroon"
                          ]
                        },
                        "sp-css-backgroundColor-BgDarkRed sp-field-fontSizeSmall sp-css-color-WhiteText",
                        {
                          "operator": ":",
                          "operands": [
                            {
                              "operator": "==",
                              "operands": [
                                "[$Color]",
                                "Gray"
                              ]
                            },
                            "sp-css-backgroundColor-BgGray sp-field-fontSizeSmall sp-css-color-WhiteText",
                            {
                              "operator": ":",
                              "operands": [
                                {
                                  "operator": "==",
                                  "operands": [
                                    "[$Color]",
                                    "Orange"
                                  ]
                                },
                                "sp-css-backgroundColor-BgOrange sp-field-fontSizeSmall sp-css-color-WhiteText",
                                {
                                  "operator": ":",
                                  "operands": [
                                    {
                                      "operator": "==",
                                      "operands": [
                                        "[$Color]",
                                        "Lime"
                                      ]
                                    },
                                    "sp-css-backgroundColor-BgSage sp-css-borderColor-SageFont sp-field-fontSizeSmall sp-css-color-BlackText",
                                    {
                                      "operator": ":",
                                      "operands": [
                                        {
                                          "operator": "==",
                                          "operands": [
                                            "[$Color]",
                                            "Purple"
                                          ]
                                        },
                                        "sp-css-backgroundColor-BgPurple sp-field-fontSizeSmall sp-css-color-WhiteText",
                                        {
                                          "operator": ":",
                                          "operands": [
                                            {
                                              "operator": "==",
                                              "operands": [
                                                "[$Color]",
                                                "Teal"
                                              ]
                                            },
                                            "sp-css-backgroundColor-BgTeal sp-field-fontSizeSmall sp-css-color-WhiteText",
                                            {
                                              "operator": ":",
                                              "operands": [
                                                {
                                                  "operator": "==",
                                                  "operands": [
                                                    "[$Color]",
                                                    "Gold"
                                                  ]
                                                },
                                                "sp-css-backgroundColor-BgGold sp-field-fontSizeSmall sp-css-color-BlackText",
                                                {
                                                  "operator": ":",
                                                  "operands": [
                                                    {
                                                      "operator": "==",
                                                      "operands": [
                                                        "[$Category]",
                                                        ""
                                                      ]
                                                    },
                                                    "sp-css-backgroundColor-BgLightBlue sp-css-color-LightBlueFont",
                                                    ""
                                                  ]
                                                }
                                              ]
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      },
      "txtContent": "[$Color]"
    }
    

    Result:

    User's image


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.