cssuser-interfacenext.jsantdant-design-pro

Why does my Ant Design CSS breaks while the application is in loading state?


I'm experiencing a styling issue in my application that uses Ant Design. While the application is in a loading state (e.g., during initial page load or lazy-loading of components), the Ant Design styles appear broken or not applied correctly. Once the application finishes loading, the styles are rendered properly.

Has anyone else encountered this problem? What are the best practices to ensure Ant Design styles are consistently applied, even during the loading phase?


Solution

  • I guess the issue is with SSR, need to inject styles as soon as possible. Here is official manual from Next, depends on your router there are 2 different solutions. If you want - post here details what version of router you have and I will help you with code examples.