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

Is there any way to load styles conditionally? #191

Open
matheenpasha opened this issue Feb 8, 2021 · 1 comment
Open

Is there any way to load styles conditionally? #191

matheenpasha opened this issue Feb 8, 2021 · 1 comment

Comments

@matheenpasha
Copy link

matheenpasha commented Feb 8, 2021

We have isomorphic react rendering for our application.
We are trying to implement dark/light themes using user preferences. Is there any way we can load light.scss or dark.scss based on a flag/variable?

Any help is appreciated. Thanks.

"css-loader": "^2.1.1"
"isomorphic-style-loader": "^5.1.0"

@maurocen
Copy link

Why don't you use the prefers-color-scheme: dark media query as explained in this article? I think it's a better solution and it seems to be supported by most of all popular browsers

If you want to load styles conditionally because of data transfer restrictions, then I don't know 😅 but I'd use a HOC to specify the desired styles before rendering.

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