Skip to content

Conversation

@creido-welly
Copy link
Contributor

@creido-welly creido-welly commented Jul 26, 2021

Context

Proof of concept for scoping of CSS variables i.e. not within a :root { } block.

The scoping demonstrated in this file provides very succinct and I would argue more readable code and results in far fewer variables. This works well when being consumed as a package. Further discovery work should be done to see how this could be optimised for theming.

Caveat

Scoped variables do not work well with CSS variable compiling using a Postcss plugin such as postcss-css-variables or postcss-custom-properties.

See below a summary of how CSS properties compile to hex values:

Works with :root variables Works with scoped variables
Main app Yes Yes
Package Yes Not reliable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants