-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
Generate @media styles dynamically #322
Comments
Have you considered adding these methods in the theme itself ? Like const pigmentConfig = {
theme: {
// ... rest of the theme,
lessThan: (breakpoint: keyof typeof breakpoints) => {
return `@media (max-width: ${breakpoints[breakpoint] - 1}px)`;
},
greaterThan: (breakpoint: keyof typeof breakpoints) => {
return `@media (min-width: ${breakpoints[breakpoint]}px)`;
},
} Then in your source, you can do
|
Hi @brijeshb42 . Thank you, that's exactly what I was looking for! Works great. |
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note @acomanescu How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
Summary
I have a case where I want to define my breakpoints in a JS file since CSS variables cannot be used in
@media
selectors and I am not able to generate the styles dynamically, even if that can be done at build time and not at runtime.Examples
Apparently this results in an error:
Error: greaterThan is not defined
.I wasn't able to find any resource about this. Is it possible?
Motivation
This allows us to have a global way to define the media breakpoints.
Search keywords: styles, media
The text was updated successfully, but these errors were encountered: