Closed dfernandez-asapp closed 4 years ago
As a workaround, if you nest the ThemeProvider
object it works:
<ThemeProvider theme={theme1}>
<Typography>Style 1</Typography>
<ThemeProvider theme={theme2}>
<Typography>Style 2</Typography>
</ThemeProvider>
</ThemeProvider>
Duplicate of #15914
With multiple
ThemeProvider
tags, the last theme in use will override theMuiTypography
CSS classes.Current Behavior 😯
In the following code:
The style of the first
h5
will use the style defined incustomTheme
.By looking at the HTML, what I see is that the CSS classes for Typography are not dynamic. So the new styles for the second variant overrides the styles of the first:
Generated HTML code:
Expected Behavior 🤔
The component should reflect the theme provided by the
ThemeProvider
, without affecting global styles.Steps to Reproduce 🕹
https://codesandbox.io/s/goofy-haze-8nxd7?fontsize=14&hidenavigation=1&theme=dark
Steps:
createMuiTheme
Typography
component with one themeTypography
component with the other themeTypography
components will use the settings from the last theme.Context 🔦
Your Environment 🌎