Repository navigation
Are CSS Custom Properties (--variables) fully supported in GrapesJS? #6817
Replies: 3 comments
|
They are supported by the core parser, but I wouldn't call every Style Manager path fully transparent yet. I tested your exact example against current {
'--primary-color': '#F26418',
color: 'var(--primary-color)',
border: '1px solid var(--primary-color)'
}Serializing the rule produced the same declarations again. There is also an existing parser test for custom-property declarations. The awkward part is shorthand/composite properties. The GrapesJS parser guide specifically notes that Your |
|
I wrote this plugin, in use in Silex and works well |
|
I hit this building a block library. In the browser parser, Workaround: write longhands only. I tested about 70 properties in Chrome (GrapesJS 0.22.16) and listed them here: https://vaibhavbansal26.github.io/grapesjs-advance-components/#define (under "Things to know"). Disclosure: this comes from my plugin, grapesjs-advance-components, which has a CSS check for it. |
Uh oh!
There was an error while loading. Please reload this page.
I would like to clarify whether CSS Custom Properties (CSS variables) are fully supported in GrapesJS.
For example, when using CSS like:
the CSS variable is valid CSS and works correctly in the browser.
However, I'm seeing issues when working with CSS variables inside GrapesJS, particularly when parsing/managing styles and using them through the Style Manager.
For example:
does not always appear to behave as expected when the style is processed by GrapesJS.
Questions
Does GrapesJS officially support CSS Custom Properties such as:
and:
Are CSS variables expected to be preserved as-is when GrapesJS parses and serializes CSS?
Is there any recommended way to use CSS variables with the Style Manager?
Are there known limitations, especially when CSS variables are used inside shorthand or composite properties?
For example:
Should GrapesJS preserve these declarations exactly, or does the CSS parser/style manager resolve or transform them internally?
I'm mainly trying to understand whether this is supported behavior, a known limitation, or something that should be addressed in GrapesJS.
A clarification on the intended level of CSS Custom Property support would be very helpful before I look into a potential fix.
All reactions