Material UI theme global Dense setting

青春壹個敷衍的年華 提交于 2019-12-24 16:54:27

问题


Is there a way to set global Dense setting preferably somewhere inside theme config? I'm building applications exclusively for desktop users and would like more information to be on the screen.

Gmail already has this option

And many individual components have property to make them more compact.


回答1:


You can set default values for any Material-UI component props. See the documentation here: https://material-ui.com/customization/globals/#default-props.

For instance to default all Material-UI List components to be dense, you would have the following in your theme:

const theme = createMuiTheme({
  props: {
    MuiList: {
      dense: true
    }
  }
});

For aspects that can't be controlled using props, you can use the overrides key of the theme to override CSS for each component.



来源:https://stackoverflow.com/questions/56400861/material-ui-theme-global-dense-setting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!