SharePoint List Header- JSON coding to change colour of font for free text field, date field and choice field

Harry N Nomikos 1,336 Reputation points
2023-09-25T11:40:53.8766667+00:00

Hi Team,

I've got 3 columns on my SharePoint list header where I want to change the colour of the font to be a light grey for the values and keep the column name as white. View below coding and I've circled the values I want to change to light grey

Free text field:

User's image

JSON Coding:

                    "elmType": "div",
                    "txtContent": "=if ([$Title] == '', 'Initiative Name:', 'Initiative Name: ' + [$Title])",
                    "attributes": {
                        "class": "ms-fontColor-white ms-fontWeight-bold ms-fontSize-12"

Date Field:
User's image

JSON Coding:

                    "elmType": "div",
                    "txtContent": "= 'Go Live Date: ' + toLocaleDateString([$GoLiveDate])",
                    "attributes": {
                        "class": "ms-fontColor-white ms-fontWeight-bold ms-fontSize-12"

Choice Field (for any selection, I want the values to be in light grey font:

User's image

JSON Coding:

                    "elmType": "div",
                    "txtContent": "=if ([$OriginatingBusinessUnit_x002f_Do] == '', 'Originating Business Unit:', 'Originating Business Unit: ' + [$OriginatingBusinessUnit_x002f_Do])",
                    "attributes": {
                        "class": "ms-fontColor-white ms-fontWeight-bold ms-fontSize-12"

Thanks team

Regards,
Harry

Microsoft 365 and Office SharePoint For business Windows
0 comments No comments
{count} votes

Accepted answer
  1. Ling Zhou_MSFT 23,620 Reputation points Microsoft External Staff
    2023-09-26T02:32:04.3266667+00:00

    Hi @Harry N Nomikos,

    Thank you for posting in this community.

    1.Initiative Name

    {
      "elmType": "div",
      "children": [
        {
          "elmType": "span",
          "attributes": {
            "class": "ms-fontColor-white ms-fontWeight-bold ms-fontSize-12"
          },
          "txtContent": "=if ([$Title] == '', 'B&PB-Change and Readiness Tracker (CART)', 'Initiative Name: ')"
        },
        {
          "elmType": "span",
          "attributes": {
            "class": "ms-fontColor-gray100 ms-fontWeight-bold ms-fontSize-12"
          },
          "txtContent": "=if ([$Title] == '', '', [$Title])"
        }
      ]
    }
    

    enter image description here

    2.Go Live Date

    {
      "elmType": "div",
      "children": [
        {
          "elmType": "span",
          "txtContent": "Go Live Date: ",
          "attributes": {
            "class": "ms-fontColor-white ms-fontWeight-bold ms-fontSize-12"
          }
        },
        {
          "elmType": "span",
          "txtContent": "=toLocaleDateString([$GoLiveDate]",
          "attributes": {
            "class": "ms-fontColor-gray100 ms-fontWeight-bold ms-fontSize-12"
          }
        }
      ]
    }
    

    enter image description here

    3.Originating Business Unit

    {
      "elmType": "div",
      "children": [
        {
          "elmType": "span",
          "attributes": {
            "class": "ms-fontColor-white ms-fontWeight-bold ms-fontSize-12"
          },
          "txtContent": "=if ([$OriginatingBusinessUnit_x002f_Do] == '', 'Originating Business Unit:', 'Originating Business Unit: ')"
        },
        {
          "elmType": "span",
          "attributes": {
            "class": "ms-fontColor-gray100 ms-fontWeight-bold ms-fontSize-12"
          },
          "txtContent": "=if ([$OriginatingBusinessUnit_x002f_Do] == '', '', [$OriginatingBusinessUnit_x002f_Do])"
        }
      ]
    }
    

    enter image description here


    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.

    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.