简体   繁体   中英

Material-UI TreeView height

Does anyone know how to set material-ui TreeView fixed height or height fitted to display? 在此处输入图像描述

I want scrollbar to be shown when TreeView content height become 100 for example or 100% of display height. Now when I expand my tree all content that didn't fit, goes away of the display bottom.

Just modify the root style of TreeView component. Add your desirable height to the height attribute and then assing overflow to auto to make the whole TreeView component scrollable. Sandbox

const useStyles = makeStyles({
  root: {
    height: "50px",
    flexGrow: 1,
    maxWidth: 400,
    overflow: "auto"
  }
});
<TreeView
      className={classes.root}
      defaultCollapseIcon={<ExpandMoreIcon />}
      defaultExpandIcon={<ChevronRightIcon />}
    >

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM