Repository navigation
Description
- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
When using createTheme and changing the palette to dark mode the rest of the provided palette appears to be ignored.
Expected Behavior 🤔
I should be able to select dark mode and customize a couple of the palette's colours.
Steps to Reproduce 🕹
See the example where I use createTheme, select dark mode and set the primary colour to red. The display shows an AppBar which I want to use my intended primary colour (red).
https://codesandbox.io/s/material-ui-5-0-3-dark-theme-forked-7pfe3?file=/src/App.js:190-208
As you can see the app bar actually has a grey background. If I remove the mode: "dark" from the code then the app bar does go red but of course the rest of the palette becomes light mode.
Context 🔦
I want a slightly altered version of the dark mode palette. I shouldn't have to manually set every single colour just to change a few.
Activity
abhinav-22-tech commentedon Oct 10, 2021
If we use
enableColorOnDarkin<AppBar>it worked.Please check out the given below link:
https://codesandbox.io/s/material-ui-5-0-3-dark-theme-forked-p3bji?file=/src/App.js
Mossop commentedon Oct 10, 2021
Ok, is there some way to not need to add that attribute to every element I want coloured correctly? This worked ok in v4.
siriwatknp commentedon Oct 11, 2021
Yes, you can specify the default props in
createThemelike this, it will apply to all AppBar under ThemeProvider:https://codesandbox.io/s/material-ui-5-0-3-dark-theme-forked-o6glf?file=/src/App.js
[-]Cannot customize palette in dark mode[/-][+][AppBar] Color does not apply in dark mode[/+]siriwatknp commentedon Oct 11, 2021
I think this can be improved by adding one example in the docs. I marked this as "Good First Issue" in case anyone wants to work on it.
oliviertassinari commentedon Oct 11, 2021
There is a section in the documentation about this problem: https://mui.com/components/app-bar/#enable-color-on-dark. Is the proposed solution to add an illustration demo to it?
abhinav-22-tech commentedon Oct 11, 2021
@siriwatknp Can you clarify more in detail?
Do I have to update the docs from -
to this -
siriwatknp commentedon Oct 11, 2021
@oliviertassinari Yes, I think it should give more clarity to developers.
siriwatknp commentedon Oct 11, 2021
I think there should be a demo in
Enable color on darksection.felipeLx commentedon Oct 11, 2021
hi, newbie question. In the case that want to refactor the code, can the issue be fixed with the line of code below?
createTheme({
.
.
palette: {
...children.color,
})
Kaid00 commentedon Oct 11, 2021
Yes that would give more clarity to developers, I would like to work on it
siriwatknp commentedon Oct 12, 2021
@Kaid00 👍. Awesome, go ahead. Feel free to tag me as a reviewer when you have a PR up.
Wimukti commentedon Oct 18, 2021
Hi everyone. I also found that including a demo would give more clarity to developers as I faced the same thing on finding a solution for this same issue. So I have added a demo to this section in the documentation and created a pull request.
@siriwatknp can you review it, please. #29129