Gradients not working in Component Parameters

Hello,

I have build some components where i want to have a parameter for the background color. I am using this code for the background colors:

{
  "backgroundColors": {
  "type": "group",
  "label": "Background colors",
  "params": {
    "backgroundColorBlock": {
      "label": "Background colour block",
      "type": "color",
      "initial": "transparent"
    },
    "backgroundColorCard": {
      "label": "Background colour card",
      "type": "color",
      "initial": "transparent"
    }
  }
},

And i’m inserting the value of the parameter in my section background like this:
{{ param.backgroundColors.backgroundColorBlock }}

When selecting a sollid color the color gets applied to the background color of the section as inteneded but when creating a gradient or selecting a gradient from my global color manager it doesn’t show at all.

Am i missing something? Is this not supported or is it bugged?

Thanks in advance!

Hey @100leiden,

Are you missing something? Is this not supported or is it bugged?

You are not missing anything obvious, and it is not a bug—it is an architectural limitation of how CSS and Cornerstone/Pro handle colors versus backgrounds.

Here is why this happens:

  1. type: "color" outputs a color value or CSS gradient function, but CSS background-color only accepts solid colors:

    • In CSS, background-color only accepts standard single color values (hex, rgba, hsl, etc.).
    • A gradient is not a color in CSS; it is an image data type (linear-gradient(...) / radial-gradient(...)).
    • In CSS, a gradient must be applied to background-image or the shorthand background property, never background-color. If a browser encounters background-color: linear-gradient(...), it considers the declaration invalid and ignores it completely.
  2. Cornerstone Element Controls separate Solid Color vs. Background Layers:

    • In standard Pro/Cornerstone elements (like Sections, Rows, Divs), the built-in “Background” control has separate sub-controls:
      • The solid color picker targets background-color.
      • The “Advanced” / Background layers (lower and upper) target gradients and images via background-image.
    • When you bind {{ param.backgroundColors.backgroundColorBlock }} directly to the element’s primary Background Color field in the inspector, Cornerstone writes it into the element’s CSS background-color rule, which causes the browser to reject gradients.

How to solve it

Depending on where you are outputting the value:

  • If you are using Inline CSS / Custom CSS / Element CSS:
    Use the shorthand background property instead of background-color:

    $el {
      background: {{ param.backgroundColors.backgroundColorBlock }};
    }
    

    CSS background accepts both solid colors (e.g., #ffffff) and gradient images (e.g., linear-gradient(...)).

  • If you want standard element background controls:
    Bind the parameter to the Background shorthand or Element CSS rather than the dedicated “Background Color” input field in Cornerstone’s inspector.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.