简体   繁体   中英

How add a icon in my TreeItem Material UI 4

I have a menu made with MATERIAL UI 4, it is composed of a first TreeItem with my main menu and a second TreeItem with my submenu.

I would like to add a specific icon to each label of the main menu.

How can I do?

Is it possible that when I click on two drop-down menus, the first is reset by default ( no dropdown ).

    {stoMenu && (
      <TreeView
        style={test.menu}
      >
        {Menu.root.children.map(test=> {
          return (
            <TreeItem
              key={test.nodeId}
              nodeId={test.nodeId}
              label={test.text}
            >
              {test.children.map(child => {
                return (
                  <TreeItem
                    key={child.nodeId}
                    nodeId={child.nodeId}
                    label={child.text}
                  >
                    <Redirect to={child.id} />
                  </TreeItem>
                );
              })}
            </TreeItem>
          );
        })}
      </TreeView>
    )}

They have great example how to do that https://codesandbox.io/s/material-demo-ui4dx

Also be careful with TreeView component as it is still inLab and can be with some issues and not finished implementation.

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