theme.spacing()的功能如何?

问题描述 投票:0回答:1

根据material-ui中的文档,它在组件之间提供了空间。但是我可以在这里得到高度和宽度的方式:

                           `width: theme.spacing(20),
                           height: theme.spacing(15)`

theme.spacing()如何在此处设置宽度和高度。

reactjs react-native material-ui materialize
1个回答
0
投票
const theme = createMuiTheme({
  spacing: 8,
});

定义主题后,您将获得一个间距值。默认情况下,此值为8px。因此,当您调用theme.spacing(20)时,如果spacing value8,则仅返回20 * 8 => 160px

来源:https://material-ui.com/customization/spacing/

© www.soinside.com 2019 - 2024. All rights reserved.