question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

styles flickering in dev with tailwind + css modules

See original GitHub issue

Bug report

Describe the bug

I’m using tailwindcss with css modules and I notice that the first time the page loads, all my styles are not loaded. Trying to figure it put what was happening, I run the tailwindcss example and added a style from a css module and it happens there too, even when built for prod.

To Reproduce

Run the example from https://github.com/zeit/next.js/tree/canary/examples/with-tailwindcss

Add a index.module.css file with some style

add the styles form the css module in the index.js page

Expected behavior

Without the use of the css modules, all styles are loaded fine the first time, without flickering. Same behavior is expected using css modules

Screenshots

May-03-2020 14-06-19

System information

  • OS: macOS
  • Browser (if applies) [e.g. chrome, safari]
  • Version of Next.js: v9.3.6
  • Version of Node.js: v13.12.0
  • Version of tailwindcss: v1.4.4

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:14
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

9reactions
fadonascimentocommented, Jun 3, 2020

There is a workaround to resolve this problem Create a custom “_document.js” and add the class “no-fouc” in the Html component Create a custom “_app.js” and add the following code in the “componentDidMount

const removeFouc = (foucElement) => {
      foucElement.className = foucElement.className.replace('no-fouc', 'fouc')
    }
 removeFouc(document.documentElement)

Add add this styles in the global styles:

.no-fouc {
  visibility: hidden;
 opacity: 0;
}

.fouc {
 visibility: visible;
 opacity: 1;
}
7reactions
Timercommented, Jun 22, 2020

This should be fixed in next@^9.4.5-canary.15! Please upgrade and let us know.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nextjs css flickering - Stack Overflow
The solution was to create a custom pages/_document.js page with: import React from 'react'; // Modules import Document, { Html, Head, Main, ...
Read more >
Using Material UI with Next.js 13 and Tailwind CSS (Part 2)
The flickering is the result of the sequence of CSS applied to the button. ... the styles from Tailwind CSS over those from...
Read more >
How to make a flicker-free dark theme toggle with Next.js ...
Today, we're going to add a dark/light theme toggle to a Next.js application using TailwindCSS with no theme flickering at all.
Read more >
Page blinking when using tailwindcss - GoRails
I am trying to use tailwindcss on a 5.2 ruby on rails application with webpack. Everything is set up and works well according...
Read more >
[Solved]-Nextjs css flickering-Reactjs - appsloveworld
The solution was to create a custom pages/_document.js page with: import React from 'react'; // Modules import Document, { Html, Head, Main, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found