Not planned
Description
What would you want to propose?
Hello! We encountered the fact that the type construction is not supported
:root.ClassName {
--custom-props: value
}
Suggested solution
In source code we found that the package does not process the class of the :root
element no
export const ROOT_SELECTOR_REGEX = /^:root$/i;
```need to modify the regular expression to support the className``
Additional context
No response
Validations
- Follow our Code of ConductCheck that there isn't already an issue that request the same feature to avoid creating a duplicate.
Would you like to open a PR for this feature?
- I'm willing to open a PR
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
romainmenke commentedon May 20, 2025
Hi @movie4,
Thank you for making this request.
Unfortunately this plugin is purely a fallback for very old browser versions that do not support custom properties.
Within the scope of the plugin it would be incorrect to provide automatic fallback for anything other than
:root, html, ...
.Providing fallbacks for
:root.some-class
would be incorrect.Are you trying to inject specific variables into multiple output/bundle files?
movie4 commentedon May 20, 2025
Thanks for the quick reply!
We want to change variables by class.
We solved this situation using the
:root:where(.className)
— it worksromainmenke commentedon May 20, 2025
Do you mean: "this issue can be closed" or "this selector works"?
This plugin doesn't support changing variables by classnames.
It only supports
:root, html, ...
and this is by design.We can not change this :)
movie4 commentedon May 20, 2025
this selector works as we need it
romainmenke commentedon May 20, 2025
Yeah, we can't change the behavior of the plugin :)
You have several options:
var()
Maybe this tool can help?
https://www.npmjs.com/package/@csstools/postcss-global-data