Repository navigation
[system] Put styles in CSS sub-layers by default - #49601
Draft
aarongarciah wants to merge 6 commits into
Draft
aarongarciah wants to merge 6 commits into
aarongarciah wants to merge 6 commits into
Conversation
Deploy previewBundle size
PerformanceNo regressions in 32 benchmarks · ran 4m 04s · details Check out the code infra dashboard for more information about this PR. |
Theme objects written by hand or built without `createTheme()` don't set it, and `hasCssLayers()` already treats a missing value as "use `modularCssLayers`".
CI runs the unit tests with --no-isolate, so the setup file runs again for each test file in the same document. The patched appendChild kept the first file's element map while the cleanup cleared the new one, so layer style elements leaked into later files.
- Don't change cached serialized styles when layering them, so a component renders the same with `cssLayers: false` after it rendered with layers. - Layer style objects that start with an `@layer` block. - Declare the layer order under a ThemeProvider without layers, and for scoped themes. - Keep the app's own layers, layer order statements and `@import` out of `mui.global`. - Layer styles that are serialized already in GlobalStyles, and copy them instead of changing them in the `enableCssLayer` caches. - Turn layers off with `modularCssLayers: false`.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Draft for v10: turns on the CSS sub-layers (
mui.global,mui.components,mui.theme,mui.custom,mui.sx) by default.cssLayers: falseopts out.Open issues:
styleOverrides,styled()andsxnow beat the components' state styles (:hover,.Mui-disabled,.Mui-selected).muiis always the lowest layer: other layers (like Tailwind's preflight) beat it, and an order set in the app's CSS can't move it.button { padding: 0 }now beat Material UI.@layer, so style assertions in jsdom tests break.Playground: https://deploy-preview-49601--material-ui.netlify.app/experiments/css-sub-layers/