-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[material-ui][Paper] Wrong background color shading when elevation=0 and using dark theme with cssVariables
#43683
Comments
Thanks for reporting the issue. The workaround is to use the theme: const theme = createTheme({
cssVariables: true,
colorSchemes: {
dark: true,
},
defaultColorScheme: 'dark',
components: {
MuiPaper: {
variants: [
{ props: { elevation: 0 }, style: { '--Paper-overlay': 'none'} },
]
}
}
}); |
This fix can be reverted after mui/material-ui#43683 is resolved.
Created PR to fix it: #43723 |
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note We value your feedback @viliket! How was your experience with our support team? |
Good morning, Steps:
On dialog paper I get: style="
--Paper-shadow: var(--mui-shadows-24);
--Paper-overlay: var(--mui-overlays-24);
" More detailed code: <div
class="MuiDialog-container MuiDialog-scrollPaper css-8azq84"
role="presentation"
tabindex="-1"
style="opacity: 1; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1)"
>
<div
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation24 MuiDialog-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthXl MuiDialog-paperFullWidth css-1e4g5ku"
role="dialog"
aria-describedby="dialog-content"
aria-labelledby="dialog-title"
style="
--Paper-shadow: var(--mui-shadows-24);
--Paper-overlay: var(--mui-overlays-24);
"
>
</div>
</div> Many thanks, |
Hi @mauro-ni, I faced the same issue while trying to customize the Drawer in a dark theme. As referenced in this documentation,
So the solution is to set the This is how i did it with the
|
@carlospisarello many thanks for the reply. I am aware of this possibility, which is used to restore the mode present in MUI 4. Mauro |
Steps to reproduce
Link to live example: https://stackblitz.com/edit/github-tucwch?file=src%2FApp.tsx
Steps:
ThemeProvider
with a theme created usingcreateTheme
which hascssVariables: true
,colorSchemes: { dark: true }
anddefaultColorScheme: 'dark'
.Paper
component withelevation={0}
and try nesting it with anotherPaper
component with a higher elevation, e.g.elevation={24}
.Current behavior
The
Paper
component withelevation={0}
has wrong background color shading which it inherits from the parentPaper
component. This happens because due to a bug the Paper component:https://github.com/mui/material-ui/blob/64aaf564c82cd8bd709116ad38123dbcab8d3bfb/packages/mui-material/src/Paper/Paper.js#L121C54-L121C63
where the
--Paper-overlay
CSS variable value is set astheme.vars.overlays?.[elevation]
. The issue is the that thetheme.vars.overlays
object has no entry for the0
elevation so this CSS variable ends up undefined. Therefore thePaper
component has no--Paper-overlay
CSS variable defined so it wrongly inherits it from the closest parent (if exists) and therefore thebackground-image
property has wrong value leading to wrong shading.Expected behavior
The
Paper
component withelevation={0}
should have correct background color shade when using dark color scheme and CSS variables.Context
This problem occurs e.g. if one tries to use an AppBar / Paper component with
elevation={0}
within a Dialog component with a theme with CSS variables and dark color scheme. This causes the AppBar / Paper component to display with wrong background color as it inherits it wrongly from the Dialog component.Your environment
npx @mui/envinfo
Using Stackblitz for the bug reproduction so just listing the dependencies as is.
Search keywords: paper cssvariables elevation background color
The text was updated successfully, but these errors were encountered: