我使用Nextjs 14
从MUI 5.15.15
获得这个Toolbar
组件
它的默认右和左填充为"24 px",我无法使用在MUI文档上找到的任何记录方法来重写这些填充.
我try 过的是:
1 - Overriding root styles in the theme object
components: {
MuiToolbar: {
styleOverrides: {
root: {
paddingRight: '0',
paddingLeft: '0',
},
},
},
}
除非我加!important
,否则这是行不通的
2 - Using styled
const StyledToolbar = styled(Toolbar)<ToolbarProps>(() => ({
padding: '40px 114px',
}))
再说一次,除非我添加!important
,否则这才有效.
3 - Same thing when using the sx
attribute
如果我必须添加!important
标志,那么这些解决方案的意义何在?我一定错过了什么,但又想不出是什么.