Home > Software engineering >  Create react app - Is it possible to inject a specific stylesheet last?
Create react app - Is it possible to inject a specific stylesheet last?

Time:05-31

Am using import "./App.css" in index.js

Is there anyway to make sure this style is injected last, amongst the other injected styles?

To clarify, I'd specified import "./App.css" last in my app. However, MUI is able to inject itself last instead.

CodePudding user response:

It is not possible to inject something after MUI styles. MUI uses emotion which is a CSS-in-js implementation. CSS-in-JS libraries load CSS on demand using style tags. That is why it ends up adding styles very last.

You can hack your way out of it by dynamically and lazily injecting your link tag. But even then MUI may end up adding styles as and when different components get loaded by your application views.

  • Related