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

Styled component function syntax not applying styles in correct order #297

Closed
tannerlinsley opened this issue Jan 18, 2021 · 3 comments
Closed

Comments

@tannerlinsley
Copy link

The bug is best visible in this codesandbox reproduction: https://codesandbox.io/s/hungry-curran-m2zvw?file=/src/App.js.

Expectation: Only the "active" tab should be white in dark mode
Actual: All of the tabs are white in dark mode.

@tannerlinsley
Copy link
Author

Another note I forgot is that seems to only happen in dark mode, but there could be deeper issues afoot in light mode that I'm just not sussing out.

@ben-rogerson
Copy link
Owner

ben-rogerson commented Jan 20, 2021

Thanks for the great bug reproduction.

This issue looks like it's the &bug introduced in [email protected].

I can only think of these workarounds right now:

  • Use css variables for theming - you can see an advanced approach here
    The idea is to set the css vars in :root or body (using the globalStyles import from styled-components), then set colors in tailwind that use those variables (eg: colors: { "primary": "var(--color-primary)" }). You can then toggle the global variable with js to change the theme.
  • Drop back a version 5.1.1 in styled-components - here's your working demo
  • Or switch to emotion - It doesn't have the & issues styled-components has right now.

@ben-rogerson
Copy link
Owner

ben-rogerson commented Jan 30, 2021

Closing this as this has been covered in #310
If dropping back to styled-components 5.1 didn't solve this, feel free to re-open 👍

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