material-table icon indicating copy to clipboard operation
material-table copied to clipboard

Including material-table overrides material-ui theme

Open yoonsio opened this issue 7 years ago • 17 comments

Describe the bug

material-table loads default material-ui styles again overriding theme styles.

To Reproduce

Steps to reproduce the behavior:

  1. Create MUI theme and change theme.typography.fontFamily
  2. Load theme using MuiThemeProvider
  3. Create React page and ensure theme is applied
  4. Create React page with MaterialTable
  5. Look at developer tools to find typography styles have been overriden.

Expected behavior

Should not have duplicated material-ui style elements after including MaterialTable

Screenshots

Screen Shot 2019-05-28 at 6 24 41 PM Screen Shot 2019-05-28 at 6 25 37 PM

Environment

npx create-react-app my-app --typescript
"@material-ui/core": "^4.0.0",
"material-table": "^1.37.0",

yoonsio avatar May 28 '19 22:05 yoonsio

I tested this but i think this is not MT related case. When you use a muithemeprovider it adds styles of every component that used inside.

This is normal you will see two MuiTypography styles.

 <>
        <Typography>Text1</Typography>
        <MuiThemeProvider theme={theme}>
          <Typography>Text2</Typography>
        </MuiThemeProvide>
</>

mbrn avatar May 29 '19 05:05 mbrn

I have the same issue i'm trying to figure out. when i add the tag in my page, the whole material-ui theme changes. It's the only module that does that. I'll let you know if i find how to fix it. Thanks.

Edit: I noticed this issue does not exists in 1.38.0 so that's what i'm going to roll with. Thanks.

zumdahl76 avatar Jun 11 '19 14:06 zumdahl76

I will take a look again.

mbrn avatar Jun 13 '19 08:06 mbrn

I'm having the same problem. After the module is loaded, the MaterialUI theme (eg. button styles) is broken.

PS: I'm using NextJS

Clem- avatar Jun 26 '19 14:06 Clem-

I can confirm this happens with .MuiButtonBase-root too.

Is there a way to make your styles more specific at all?

woffleloffle avatar Jun 27 '19 09:06 woffleloffle

+1

bilel-noomene avatar Jul 01 '19 09:07 bilel-noomene

+1

ahomatthew avatar Jul 10 '19 03:07 ahomatthew

I had to go back to 1.36.0 to get it to stop behaving this way.

ahomatthew avatar Jul 10 '19 03:07 ahomatthew

I am having this issue as well. In my case it affected Button styles and Textfield's select options. Both utilized .MuiButtonBase-root. I am using Material UI 4 with ThemeProvider and styled-components. Downgrading to 1.36 fixed the issue.

devopsjosh avatar Jul 11 '19 18:07 devopsjosh

was this fixed? I used 1.57 and having the same issue.

wolfdgreat avatar May 11 '20 09:05 wolfdgreat

Same problem here. Other components that use material UI have their style changed when I include the material-table.

Also fixed by downgrading to 1.36.

I had a problem with editing in 1.36 so I tried 1.52 and it works without overwriting the styles too.

m3h0w avatar May 26 '20 12:05 m3h0w

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required.

stale[bot] avatar Aug 24 '20 14:08 stale[bot]

Issue is persistent on 1.69

bishoym avatar Aug 26 '20 12:08 bishoym

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required.

stale[bot] avatar Nov 24 '20 13:11 stale[bot]

Issue is persistent on 1.69.3

nsdonato avatar May 21 '21 17:05 nsdonato

Issue is persistent on 1.69.3 I had to go back to 1.32.0

matiquec avatar Nov 19 '21 23:11 matiquec

Added this to the top of my ThemeProvider in my application as a workaround to prevent the classnames to clash.

import { unstable_ClassNameGenerator as ClassNameGenerator } from '@mui/material/className';

ClassNameGenerator.configure((componentName) => `randomPrefix-${componentName}`);

adrianskogvold avatar Apr 20 '23 11:04 adrianskogvold