gpt4 book ai didi

reactjs - createMuiTheme 是否为缺少的属性提供默认值?

转载 作者:行者123 更新时间:2023-12-05 06:23:19 24 4
gpt4 key购买 nike

我正在使用 createMuiTheme() 创建主题:

import { createMuiTheme, responsiveFontSizes } from '@material-ui/core/styles';

const theme = responsiveFontSizes(
createMuiTheme({
palette: {
type: 'dark',
primary: {
main: '#c5cae9',
light: '#f8fdff',
dark: '#9499b7',
contrastText: '#212121',
},
secondary: {
main: '#5c6bc0',
light: '#8e99f3',
dark: '#26418f',
contrastText: '#ffffff',
},
},
typography: {
fontFamily: [
'Roboto',
'Arial',
'"Helvetica"',
'sans-serif',
].join(','),
},
}),
);

export default theme;

查看 default theme 时,我遗漏了很多属性,例如 breakpointsdirectionshadowsspacing

即使省略了这些属性,createMuiTheme() 是否提供填充这些字段的默认值?还是我必须自己提供这些值。

最佳答案

看看createMuiTheme options 签名

(Object): Takes an incomplete theme object and adds the missing parts.

是的,您的自定义主题将与 MUI 的默认主题合并。查看docs here

const options = {palette:{/*such empty*/}}

export const theme = createMuiTheme(options)

关于reactjs - createMuiTheme 是否为缺少的属性提供默认值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58511820/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com