Forum Discussion

BigBeuferd's avatar
BigBeuferd
Copper Contributor
May 06, 2019
Solved

Json colors other than the .mscolors

Hi.  I can't figure out how to assign different colors in JSON.  I can do all the .ms stuff...but their colors are horrible!! How do I use RGBA or HEX or whatever?  I don't really understand json.  ...
  • Colin Steger's avatar
    Colin Steger
    May 08, 2019

    BigBeuferd Depending on how/where you're trying to apply the color, you would need to add a "style" object after you declare an element in JSON.

     

    Depending on what element you're applying the "style" object to, you can add in a "background-color" and/or "color" attribute to change the font/background colors. You can use RGB or HEX values for either of those attributes.  

     

    "style": {
    "background-color": "#f4f4f4"
    }
     

    One thing to watch out for is your commas; if you miss a comma, your JSON will be invalid. If you use https://code.visualstudio.com/, it validates as you go. 

     

    This article does a nice job of breaking down JSON structure for view formatting.

    https://collab365.community/sharepoint-modern-view-formatting-json-part-1-2/

Resources