Closed Janpot closed 2 days ago
Some benchmarking:
ThemeProvider
, logic must be manually created by the user with React state to select light or dark theme.theme
and darkTheme
as props of the root component.theme
property and nested themes
where multiple themes can be added as object properties, and a default theme can be set.These were the first solutions that came to mind for me for this problem: https://github.com/mui/mui-toolpad/pull/3343#discussion_r1598691276
In conclusion, I think the initially proposed solution with
interface AppProviderProps {
// ...
themes?: AtLeastOne<{
light: Theme;
dark: Theme;
}>;
// unstable_adoptPaletteMode?: boolean;
}
seems fine and intuitive to use, and it's possibly the one that abstracts away the most / the simplest. It's very literal and would work with the theme switcher seamlessly.
themes defined, only one provided => use only the provided theme + remove theme switcher
What about passing just one theme directly? I feel like this would be more natural, but on the other hand it does create 2 quite different ways to define the theming (it's less consistent).
Add unstable_adoptPaletteMode, if it's true, we hide the theme switcher and we adopt the mode from the surrounding theme. This could be useful for the docs to remove the iframe from the demos.
This sounds good, we can try it!
Summary
Currently the DashboardLayout component comes with a default light theme. We should add the possibility for different color schemes and if multiple are defined, we should add a theme switcher.
API proposal:
themes
undefined => provide default light and dark themes + add theme switcherthemes
defined, only one provided => use only the provided theme + remove theme switcherthemes
defined, both provided => set both themes + add theme switcherAdditional suggestion:
Add
unstable_adoptPaletteMode
, if it'strue
, we hide the theme switcher and we adopt the mode from the surrounding theme. This could be useful for the docs to remove the iframe from the demos.Examples
No response
Motivation
No response
Search keywords: theme switcher