compiled css precedence
See original GitHub issueWhen a project is compiled, the precedence of applied CSS rules changes.
- This is not a v0.x issue.
- I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior 🤔
.MuiDialogActions-spacing > * + * {
margin-left: 8px;
}
... other styles ...
.MuiButtonBase-root {
color: inherit;
border: 0;
margin: 0;
cursor: pointer;
display: inline-flex;
outline: none;
padding: 0;
position: relative;
align-items: center;
user-select: none;
border-radius: 0;
vertical-align: middle;
justify-content: center;
-moz-appearance: none;
text-decoration: none;
background-color: transparent;
-webkit-appearance: none;
-webkit-tap-highlight-color: transparent;
}
Current Behavior 😯
.MuiButtonBase-root {
color: inherit;
border: 0;
margin: 0;
cursor: pointer;
display: inline-flex;
outline: none;
padding: 0;
position: relative;
align-items: center;
user-select: none;
border-radius: 0;
vertical-align: middle;
justify-content: center;
-moz-appearance: none;
text-decoration: none;
background-color: transparent;
-webkit-appearance: none;
-webkit-tap-highlight-color: transparent;
}
... other styles ...
.MuiDialogActions-spacing > * + * {
margin-left: 8px;
}
Steps to Reproduce 🕹
- Run a demo of Dialog on localhost to see the expected behavior
- Compile the demo and run to see the
marginLeft
of MuiDialogActions is overridden bymargin
of MuiButtonBase
Your Environment 🌎
Tech | Version |
---|---|
Material-UI | v4.1.3 |
React | v16.8.6 |
Browser | Chrome |
Issue Analytics
- State:
- Created 4 years ago
- Reactions:16
- Comments:40 (10 by maintainers)
Top Results From Across the Web
Precedence in CSS (When Order of CSS Matters)
The practice of critical CSS involves moving up CSS selectors into a higher chunk. The #1 chunk. The lowest-order and easiest-to-override chunk.
Read more >compiled css precedence #16609 - mui/material-ui - GitHub
When a project is compiled, the precedence of applied CSS rules changes. This is not a v0.x issue. I have searched the issues...
Read more >What is the order of precedence for CSS? - Stack Overflow
Here's a compilation of CSS styling order in a diagram, on which CSS rules has higher priority and take precedence over the rest:...
Read more >CSS Precedence - Jenkov.com
The term CSS Precedence covers the semantics for which CSS rules takes precedence over others, when multiple CSS rules target the same HTML ......
Read more >Atomic CSS - Compiled CSS in JS
For the list above, active state would take precedence over hover state. This ordering ensures a stable, consistent experience.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m running into an issue that may be related. If not, I will open another issue.
When building my react app in production mode (
$ npm run build
) the order of the MUI style elements is getting mixed up with my own jss style elements. However, if I run it in development ($ npm start
) everything is as expected. This is project is using 4.2.0. I have a similar project that is using 3.9.1 and it works the same both production/dev (i.e. correctly as I would expect).it seems the production mode is the issue, but I do not know where to begin looking.
The CSS specificity of
.x > * + *
is 1 then we rely onto get the CSS injection order right.
The alternative is to increase the specificity to 2. I like this idea, it would make use component agnostic (work with everybody, not just our Button)
cc @eps1lon as you were advocating for removing the import (tree-shaking) cc @NMinhNguyen as you were wondering about it
@Luucky I can’t explain the behavior of the deployment. Something is wrong in the bundling pipeline independently from my previous comment about CSS specificity. ~I can reproduce the problem with our CRA and Next.js examples~.