@material-ui/styles/ThemeProvider
should apply the theme to mui core components.
@material-ui/styles/ThemeProvider
doesn't apply the theme to mui core components.
https://codesandbox.io/s/pwm13wmj9j
| Tech | Version |
|--------------|---------|
| Material-UI | v3.8.1 |
| React | v16.7.0-alpha.2 |
Use old and new ThemeProvider.
<MuiThemeProvider theme={theme}>
<ThemeProvider theme={theme}>{children}</ThemeProvider>
</MuiThemeProvider>
You need to follow https://material-ui.com/css-in-js/basics/#migration-for-material-ui-core-users to be able to use @material-ui/styles
with @material-ui/core
Hello @joshwooding
Actually I've tried your solution with bootstrap, like you did in your codesandbox. Unfortunately, I've tried to modify it, in order to mimic my App, with the following sample: https://codesandbox.io/s/mm4x6y5l58
But everything seems fine! In my environment, the exact same code is not loaded in the right order, so my overrides are pointless:
Solved by creating a bootstrap.js
file:
import { install } from '@material-ui/styles'
install()
and importing this as soon as possible.
Docs: https://material-ui.com/css-in-js/basics/#migration-for-material-ui-core-users
Example: https://codesandbox.io/s/5k6qo87zkk
Thanks @joshwooding
@HaNdTriX example no longer works and im getting
Failed to compile
./src/index.js
Attempted import error: 'install' is not exported from '@material-ui/styles'.
This error occurred during the build time and cannot be dismissed.
I'm having the same issue on v4.2.1 but import { install } from '@material-ui/styles'
no longer works and it's not in the documentation.
@JonahGroendal The bootstrap step is no longer needed with v4, plus we recommend using @material-ui/styles
Thanks. My issue was that @material-ui/core uses @material-ui/styles as a dependency and so I had two different instances of the same package. The fix was to reinstall both, installing @material-ui/styles before core so that the styles packages get deduped. It was a pretty subtle bug but the warning provided by material-ui led me to the fix.
@JonahGroendal you saved the day
@JonahGroendal you saved the day again.
Most helpful comment
Thanks. My issue was that @material-ui/core uses @material-ui/styles as a dependency and so I had two different instances of the same package. The fix was to reinstall both, installing @material-ui/styles before core so that the styles packages get deduped. It was a pretty subtle bug but the warning provided by material-ui led me to the fix.