-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
Outlined variants of paper have wrong background-color in dark-mode when resting on an elevated paper #28408
Comments
Change https://github.com/mui-org/material-ui/blob/master/packages/mui-material/src/Paper/Paper.js#L38 to: const PaperRoot = styled('div', {
name: 'MuiPaper',
slot: 'Root',
overridesResolver: (props, styles) => {
const { ownerState } = props;
return [
styles.root,
styles[ownerState.variant],
!ownerState.square && styles.rounded,
styles[`elevation${ownerState.elevation}`], // <- Change here
];
},
})(({ theme, ownerState }) => ({
backgroundColor: theme.palette.background.paper,
color: theme.palette.text.primary,
transition: theme.transitions.create('box-shadow'),
...(!ownerState.square && {
borderRadius: theme.shape.borderRadius,
}),
...(ownerState.variant === 'outlined' && {
border: `1px solid ${theme.palette.divider}`,
}),
...(ownerState.variant === 'elevation' && {
boxShadow: theme.shadows[ownerState.elevation],
}),
...(theme.palette.mode === 'dark' && { // <- Change here
backgroundImage: `linear-gradient(${alpha(
'#fff',
getOverlayAlpha(ownerState.elevation),
)}, ${alpha('#fff', getOverlayAlpha(ownerState.elevation))})`,
}),
})); This would do the trick, wouldn't it? |
Hey @MrEbbinghaus, I have added images for reference. For the workaround, I removed the background image style on the paper by overriding it. |
Any updates? The paper color in dark mode is different after upgrading, even with backgroundImage set to none v4: v5: Edit: as a fix, I manually set the paper background to '#424242':
Seems to be mentioned here: https://mui.com/material-ui/migration/v5-component-changes/#default-background-colors I am still trying to figure out why some text is still not changed from black to white in dark mode. |
@eps1lon You tagged this issue with |
tl;dr
I propose to respect the
elevation
prop foroutlined
variants of paper with regard to the background color. (Paper becoming lighter with elevation)An outlined paper sitting on top of an elevated paper should have a relative elevation of 0.
In the current implementation, the elevation of outlined paper is absolute.
In light mode, this is fine, since the background color doesn't change.
In dark mode, paper(/material) gets lighter the higher it is.
But since an outlined paper is always at elevation 0, the background color won't get lighter.
This leads to outlined variants "punching a hole" into the paper it is resting on:
How it should look like:
Possible ways of dealing with this issue
(First the more complicated, but more general solution.
Keep track of the current absolute elevation of a sheet of paper based on the elevation the paper is sitting on, and setting the background color based on that.
I don't know how best to accomplish this. Ideas on how to do this:
This would solve the problem of non-outlined paper on paper, which is currently wrong as well.
(However, for non-outlined paper, this is less of a problem, as you can manually set the
elevation
prop to fix this issue)Respect the
elevation
prop foroutlined
variants with regard to the background color.(This does not have to be a dark mode exclusive solution.)
Related:
#21748 #18309
The text was updated successfully, but these errors were encountered: