ListSubheader can no longer be styled to match the background color of dark-mode Paper components
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 99.1k
- Forks
- 32.5k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 106
Description
Duplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Current behavior 😯
When using dark mode, if a List is created with ListSubheaders (that are sticky, the default) and placed inside of a Paper (or Card) component, the sticky headers cannot be made to match the background color of the Paper. This leads to an awkward-looking list, with inconsistent background colors:

One could change the entire List to have a different background-color than the Paper (and use that for the ListSubheaers), but that is also awkward/non-ideal, as that visually separates the list from everything else.
Expected behavior 🤔
It should be possible to consistently create a List with sticky subheaders where list items, list subheaders, and the rest of the paper all have the same background color.
Steps to reproduce 🕹
Demo:
https://codesandbox.io/s/pinnedsubheaderlist-material-demo-forked-0q1n4?file=/demo.js:438-448
Steps:
- Set the theme to dark mode
- Create a
Papercomponent (with default elevation) - Put a
ListwithListSubheadersinside thePapercomponent - Observe that the background-color of the subheaders does not match the background-color of the
Papercomponent or the rest of the list
Context 🔦
The main problem here is that in dark mode in MUI v5, elevated Paper does not use a fixed background-color, but rather uses a background-image to apply different color depending on the elevation (per https://github.com/mui-org/material-ui/pull/25522). ListSubheaders set background.paper as its background color:
https://github.com/mui-org/material-ui/blob/a9903917f919092f80d84075f39fb51d51f241f2/packages/mui-material/src/ListSubheader/ListSubheader.js#L65
One would expect that you should be able to match the background color of the Paper so that all content within the List and the rest of the paper has the same background color. This is related to this other open issue, about styling custom components: https://github.com/mui-org/material-ui/issues/27980
Your environment 🌎
`npx @mui/envinfo`
Using Chrome.
This is on my system, but reproduced with CodeSandbox as well as linked above.
System:
OS: macOS 11.6
Binaries:
Node: 14.18.2 - ~/.nvm/versions/node/v14.18.2/bin/node
Yarn: 1.22.10 - ~/repos/project/frontend/node_modules/.bin/yarn
npm: 6.14.15 - ~/.nvm/versions/node/v14.18.2/bin/npm
Browsers:
Chrome: 96.0.4664.110
Edge: Not Found
Firefox: 91.0.1
Safari: 15.0
npmPackages:
@emotion/react: ^11.7.1 => 11.7.1
@emotion/styled: ^11.6.0 => 11.6.0
@mui/base: 5.0.0-alpha.62
@mui/icons-material: ^5.2.5 => 5.2.5
@mui/lab: ^5.0.0-alpha.62 => 5.0.0-alpha.62
@mui/material: ^5.2.6 => 5.2.6
@mui/private-theming: 5.2.3
@mui/styled-engine: 5.2.6
@mui/styles: ^5.2.3 => 5.2.3
@mui/system: ^5.2.6 => 5.2.6
@mui/types: 7.1.0
@mui/utils: 5.2.3
@mui/x-data-grid: ^5.2.1 => 5.2.1
@types/react: ^17.0.19 => 17.0.19
react: ^17.0.2 => 17.0.2
react-dom: ^17.0.2 => 17.0.2
typescript: ^4.4.3 => 4.4.3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked CodeSandbox reproduction in demo.js, then inspect packages/mui-material/src/ListSubheader/ListSubheader.js at the referenced line and compare it with Paper's dark-mode elevation styling. Done means sticky ListSubheaders, list items, and the surrounding Paper visibly share the same background in dark mode without requiring an awkwardly different List background.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100