Material UI style specificity issues
See original GitHub issueSince we have multiple instances of material-ui
each one of them injects styles into the head without awareness of what the others are injecting.
Each instance only injects the styles that are needed at that moment, so you can get into weird states like this:
One instance of material-ui
renders a MenuItem
which uses both Button
and MenuItem
styles, so it injects Button
styles first and MenuItem
second so that the MenuItem
styles override Button
.
but then the other instance of material-ui
is only rendering a Button
so it injects styles for Button
and if that happens after MenuItem
then you end up with Button
> MenuItem
> Button
with Button
incorrectly overriding MenuItem
styles.
There’s a few possible fixes:
- Wrap all of JupyterLab inside of a
StylesProvider
component (the best solution, if possible) - have a classname generator with
disableGlobal
set totrue
(This will make all the Mui style names non-deterministic, so we won’t be able to override styles via css, but I believe we can override them via a theme) - create our own classname generator that allows us to create deterministic Mui classes, but with each mui instance prefixed with something custom
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
material-ui and styled override specificity issue #1253 - GitHub
I'm using styled function from styled-components to override default styles of Typography component like this:
Read more >Material UI override styles with increased specificity
I have a vertical Slider with marks and for the marks, I want to get rid of the text-transformation. I am setting the...
Read more >Style library interoperability - Material UI - MUI
In MUI, all child elements have an increased specificity of 2: .parent .child {} . When writing overrides, you need to do the...
Read more >Advanced (LEGACY) - MUI System
They gain more specificity than any other style tags on your page e.g. CSS modules, styled components. injectFirst. The StylesProvider component has an ......
Read more >Migrating to v5: getting started - Material UI - MUI
If you want to apply styles to components by importing a CSS file, you need to bump up the specificity to be able...
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
To clarify this, it’s really a function of where your
notebook-dir
is pointing relative to a git configuration. Since I always run lab with--notebook-dir=~/notebooks
and git is not configured in~/notebooks
, I did not see this problem when when invokingjupyter lab
from my elyra dev tree. However, based on this information, if I perform that same invocation, but do not add--notebook-dir=~/notebooks
, the issue reproduces. Nice find @bourdakos1!I was able to make the original issue we were seeing reproducible. The issue is the git extension, it uses
material-ui
for tabs, but the tabs only render if you are in a git initialized folder. If you run jupyter lab in a folder with git the dropdown will be broken. If you run jupyter lab in a normal non-git project folder the dropdown will render correctly