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

How to combine values with custom CSS properties? #373

Open
ertrzyiks opened this issue Mar 2, 2022 · 3 comments
Open

How to combine values with custom CSS properties? #373

ertrzyiks opened this issue Mar 2, 2022 · 3 comments

Comments

@ertrzyiks
Copy link

Hey, is it possible to reference the values variables in the custom CSS properties?

@value mycolor: #fff;

:root {
  --first-color: mycolor;
}

I see mycolor persisted as it is, I would expect it to be evaluated to #fff instead.

@IgorSzymanski
Copy link

I know this is an old issue, but maybe it might help someone in the future. It looks like you have a problem with PostCSS, and not css-modules, therefore you should use stack overflow for such questions. I do not use PostCSS, but I would assume you have to use string interpolation for it to work.

@value mycolor: #fff;

:root {
  --first-color: $(mycolor);
}

@ertrzyiks
Copy link
Author

ertrzyiks commented Oct 18, 2022

Can I use values without PostCSS? I found the reference in this repo https://github.com/css-modules/css-modules/blob/master/docs/values-variables.md

I will check if that syntax works but from what I understand $ would help only with a variable created within postcss like

$mycolor: #fff;

@IgorSzymanski
Copy link

Yes, sorry, my bad.

$mycolor: #fff;

:root {
  --first-color: $mycolor;
}

And if you also need to import them somewhere else, postcss-import looks like a solution.

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

2 participants