您是否可以使用createMuiTheme为默认背景颜色和纸张背景颜色设置不同的对比度文本颜色?

时间:2020-09-18 19:54:26

标签: material-ui material-design

对于高对比度主题,我想为Paper元素(例如ExpansionPanel / Card)提供浅色背景色,并将palette.background.default设置为深色

但是,对比的文本始终遵循背景。默认设置,因此在纸张上几乎看不见。

您可以使用createMuiTheme为background.default和background.paper设置不同的对比度文本颜色吗?

这显然行不通,但这是我要的目的:

const themeObj = {}
palette = {...initialPalette};
palette.background.defaultType = lightOrDark(palette.background.default);
palette.background.defaultContrastText = palette.background.defaultType === 'light' ? '#000' : '#FFF';

palette.background.paperType = lightOrDark(palette.background.paper);
palette.background.paperContrastText = palette.background.paperType === 'light' ? '#000' : '#FFF';
themeObj.palette = palette;
       
const theme = createMuiTheme(themeObj);

0 个答案:

没有答案