Skip to content

Can't get darkMode: 'class' to work in a styled-components + Next setup. Any tips to debug this? #294

Answered by ben-rogerson
tannerlinsley asked this question in Q&A
Discussion options

You must be logged in to vote

I've successfully tested this in a new next+sc project with the following code:

import 'twin.macro'

const DarkComponent = () => (
  <div className="dark">
    <div tw="dark:(bg-black text-white)">Black bg</div>
  </div>
)

export default DarkComponent

What I think is happening in your case Tanner, is you're either hitting the babel cache issue and/or the built-in caching within next dev server.
It's been discussed here recently but the fix has been to remove the .next cache folder and restart your dev server.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@tannerlinsley
Comment options

Comment options

You must be logged in to vote
1 reply
@tannerlinsley
Comment options

Answer selected by ben-rogerson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants