Hello, thanks for your time as always. I love the new version of MUI and it has been working great for a project that I am working on!
When defining a custom theme, I should be able to override and remove the shadows globally. With the changes specified in beta v10( https://github.com/callemall/material-ui/pull/8188 ) it looks like any custom theme specified shadows will be merged into the default shadow list, instead of overriding it. If possible, there should still be a way to replace/override the entire shadow array, as this was the case for pre-v10 beta.
Before beta v10, I was able to override shadows by supplying an empty array:
return createMuiTheme({
overrides,
palette,
typography,
shadows: []
});
This issue has affected my ability to remove shadows from my theme.
| Tech | Version |
|--------------|---------|
| Material-UI | beta v10 |
| React | 15.5.4 |
| browser | Chrome v60 |
| etc | |
You can still do the following:
const theme = createMuiTheme({
overrides,
palette,
typography,
});
theme.shadows = [];
Thank you for pointing that out, I appreciate it.
@oliviertassinari is this behaviour documented somewhere in documentation? I couldn't find it. 馃槩
@mfolnovic It's not documented explicitly. The theme is a raw JavaScript object. Any mutation can be performed on it (as long as it's still containing the required values).
From what I can see, theme.shadows = [];
will completely disable shadows on all components using theme
. What about disabling shadows on select components? (ex: AppBar itself becomes shadowless, but component in AppBar has a shadow.)
Doesn't work when working with Typescript.
@akuji1993, has anyone solved this with Typescript?
Doesn't work when working with Typescript.
@akuji1993 @littletower You probably mean that the type checker doesn't let this pass? If so please open a separate issue and follow the template.
Seems to work in typescript:
theme.shadows = [] as unknown as Theme["shadows"];
```
export const theme = createMuiTheme({
overrides: {
MuiButton: {
contained: {
boxShadow: 'none',
}}}});
Seems to work in typescript:
theme.shadows = [] as unknown as Theme["shadows"];
Sometimes throws the following error in console (x is a number. In my case it's 4):
Material-UI: this elevation x is not implemented.
To resolve it, I used your solution combined with this post as follows:
Array<string>(25).fill('none') as Theme['shadows']
Most helpful comment
From what I can see,
theme.shadows = [];
will completely disable shadows on all components usingtheme
. What about disabling shadows on select components? (ex: AppBar itself becomes shadowless, but component in AppBar has a shadow.)