Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CSS Variables instead of SASS in Themes #2739

Closed
Shogoki opened this issue Jul 29, 2020 · 5 comments
Closed

Use CSS Variables instead of SASS in Themes #2739

Shogoki opened this issue Jul 29, 2020 · 5 comments

Comments

@Shogoki
Copy link
Contributor

Shogoki commented Jul 29, 2020

Just stumbling across this. Hope this was not already discussed somewhere else..

Right now the theme variables are already exposed as CSS Variables, why not also use them inside the template instead of there SASS equivalents?
This would allow us to override those on demand without having to build a custom theme.

@hakimel any thoughts about that? I´d love to help with a PR implementing this, if this is a way to go for you.

@Shogoki
Copy link
Contributor Author

Shogoki commented Jul 29, 2020

Please see my updates in the related PR #2740

@Delapouite
Copy link

I agree that the support of CSS variables would greatly simplify the customization of themes on the fly instead of relying on SASS.

The metrics regarding their support in modern browsers is good, with 95% overall: https://www.caniuse.com/css-variables

@hakimel
Copy link
Owner

hakimel commented May 27, 2021

Makes sense to me. The PR has been merged 🚀

@hakimel
Copy link
Owner

hakimel commented Jun 8, 2021

FYI @blairmacintyre raised a good point in #2967 that the generic variable names could end up conflicting with other page styles. To avoid that, all variables names are now prefixed with r-, for example --background-color is now --r-background-color. #2968

@edemaine
Copy link

edemaine commented Jun 9, 2021

Thanks for releasing this! Here's an example of the resulting simplification.

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

No branches or pull requests

4 participants