Forum Discussion
Sandie Fry
Aug 05, 2020Copper Contributor
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 FryCopper 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" } } - jab365cloudIron ContributorNo that file you can style the a element. But have you take a look at the github columns formating sample at https://github.com/pnp/sp-dev-list-formatting/tree/master/column-samples ? You should be able to do mostly anything you need and one option would be to renegerate div with child element and style you need.