Skip to main content
deleted 4 characters in body
Source Link
Ganesh Sanap - MVP
  • 46.4k
  • 22
  • 31
  • 63

You need to add a style parameter to apply styling and this can be conditional, as you see below. In style or class I have made certain changes which should work for you

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "debugMode": true,
  "elmType": "div",
  "attributes": {
    "class": "=if(@currentField,'sp-field-severity--good','')"
  },
  "children": [
    {
      "elmType": "span",
      "style": {
        "display": "inline-block",
        "padding": "0 4px",
        "color": =if"=if([@currentField] == '', 'red', 'black')
 "
      }
    },
    {
      "elmType": "span",
      "txtContent": "@currentField"
    }
  ]
} 

You need to add a style parameter to apply styling and this can be conditional, as you see below. In style or class I have made certain changes which should work for you

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "debugMode": true,
  "elmType": "div",
  "attributes": {
    "class": "=if(@currentField,'sp-field-severity--good','')"
  },
  "children": [
    {
      "elmType": "span",
      "style": {
        "display": "inline-block",
        "padding": "0 4px",
        "color": =if([@currentField] == '', 'red', 'black')
 
      }
    },
    {
      "elmType": "span",
      "txtContent": "@currentField"
    }
  ]
} 

You need to add a style parameter to apply styling and this can be conditional, as you see below. In style or class I have made certain changes which should work for you

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "debugMode": true,
  "elmType": "div",
  "attributes": {
    "class": "=if(@currentField,'sp-field-severity--good','')"
  },
  "children": [
    {
      "elmType": "span",
      "style": {
        "display": "inline-block",
        "padding": "0 4px",
        "color": "=if([@currentField] == '', 'red', 'black')"
      }
    },
    {
      "elmType": "span",
      "txtContent": "@currentField"
    }
  ]
} 
Source Link
Akshay Randive
  • 2.9k
  • 1
  • 17
  • 31

You need to add a style parameter to apply styling and this can be conditional, as you see below. In style or class I have made certain changes which should work for you

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "debugMode": true,
  "elmType": "div",
  "attributes": {
    "class": "=if(@currentField,'sp-field-severity--good','')"
  },
  "children": [
    {
      "elmType": "span",
      "style": {
        "display": "inline-block",
        "padding": "0 4px",
        "color": =if([@currentField] == '', 'red', 'black')

      }
    },
    {
      "elmType": "span",
      "txtContent": "@currentField"
    }
  ]
}