Forum Discussion

Sandie Fry's avatar
Sandie Fry
Copper Contributor
Aug 05, 2020
Solved

SharePoint List - Conditional Formatting - Links

I'm using Conditional Formatting to turn a URL into a friendlier looking link, but I don't seem to be able to style it at all.  I'm pretty new to this conditional formatting thing, so this is more of a guess of how to do it...

 

It creates my link without an issue, but its ugly as!  Underlined, small, can't change the colour...

 

Am I approaching this the wrong way by trying to style the 'a' element?

{
   "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
   "elmType": "a",
   "txtContent": " PRODUCTION",
   "attributes": {
      "target": "_blank",
      "style": {
                "vertical-align": "middle",
                "text-decoration": "none",
                "font-weight": "bold",
                "color": "red"
            },
      "href": "@currentField"
   }
}

 

 

 

  • So it looks like I was just putting the Styling in the wrong place, I thought it had to go in "attributes"

     

     

    // AEM6 Production
    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "a",
      "style": {
        "text-decoration": "none",
        "font-size": "24px"
      },
      "txtContent": "",
      "attributes": {
        "iconName": "=if(@currentField == '0', '', 'Design')",
        "target": "_blank",
        "title": "AEM6 Production",
        "class": "ms-fontColor-themeDark",
        "href": "@currentField"
      }
    }

     

2 Replies

  • Sandie Fry's avatar
    Sandie Fry
    Copper Contributor

    So it looks like I was just putting the Styling in the wrong place, I thought it had to go in "attributes"

     

     

    // AEM6 Production
    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "a",
      "style": {
        "text-decoration": "none",
        "font-size": "24px"
      },
      "txtContent": "",
      "attributes": {
        "iconName": "=if(@currentField == '0', '', 'Design')",
        "target": "_blank",
        "title": "AEM6 Production",
        "class": "ms-fontColor-themeDark",
        "href": "@currentField"
      }
    }

     

Resources