0

I have a hyperlink column called "LinkUrl" and a text column called "CategoryTitle". I want to apply column formatting where I can Show the CategoryTitle as button and onClick, it redirects to the link in "LinkUrl". I was able to successfully achieve it using below:

 {
        "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
        "elmType": "button",
            "txtContent": "@currentField",
            "style": {
              "background-color" : "green",
              "padding": "4px 4px",
              "cursor": "pointer"
             
            }
       
        ,
        "children": [
          {
            "elmType": "a",
        "attributes": {
          "href": "[$LinkUrl]",
          "target": "_blank"
          }
        }
        ]

      }

However, now, instead of "background-color" green, I want to show a gradient as below:

linear-gradient(72.44deg, rgb(230, 251, 254) 0%, rgb(237, 221, 251) 100%);

This works on a separate CSS (without column formatting) and when I directly change it using Inspect element on above column too. However, when I save the code with above liner-gradient, it doesn't apply gradient. Only solid color works.

I even tried using "background" property instead of "background-color" and tried using "div" instead of "button" but nothing works.

Is this limitation of column view formatting?

1 Answer 1

0

I guess linear-gradient is not supported in the JSON Formatting. But you can try its workaround by preparing the svg image as per your gradient and use it as a background image.

Here are the steps for the same: https://www.linkedin.com/pulse/federico-sapia-2f

2
  • Thanks, I will try this out and share results. Commented Jul 16, 2024 at 7:02
  • @404 - Please accept and upvote this answer if it is helpful to you. Thanks. Commented Nov 5, 2024 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.