[fix] mui-stylis-plugin-rtl not wrapping css with @layer bug fixed wi… #46611
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Working on a Next.js app router and MUI project using tailwindcss for customizations. I found that when changing to
RTL
the rtl cache provider does not wrap CSS with@layer mui
even thoughenableCssLayer
is set totrue
. This ruins the tailwindcss integration because the layer ordering is not properly applied. So based on these two issues #44700 - emotion-js/emotion#3134 (comment). I refactored themui-stylis-plugin-rtl
to export a plugin factory that accepts an optinal layer name. If provided the output CSS will be wrapped with an@layer <layer-name>
and if not the output will be as is.If this pull request is merged I'm willing to update both tests and the documentation website ASAP, which isn't possible for now since there's a major change in tests which happen to use the installed version of the plugin, so updating tests isn't possible before updating the package.