Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
Mui V5 - Remove TreeView collapse/extand icons and TreeItem indentation

I'm using Mui V5 and want to change TreeView so it doesnt include collapse/extand icons since I need them to be a part of the TreeItem label component and appear on the left, not right. Also, I want to cancel the indentation of the TreeItems. how can I do that?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think that what you are trying to do with indentation cannot be directly done through TreeView or TreeItem props. You can remove icons just avoiding defaultCollapseIcon and defaultExpandIcon props.

You can always add some custom styling to achieve what you want. Here's an example to just get a TreeView without icons nor indentation.

const StyledTreeView = styled(TreeView)`
  .MuiTreeItem-group {
    margin-left: 0;
  }
`;

const StyledTreeItem = styled(TreeItem)`
  .MuiTreeItem-iconContainer {
    display: none;
  }
`;

export default function App() {
  return (
    <StyledTreeView aria-label="tree">
      <StyledTreeItem nodeId="1" label="Item 1">
        <StyledTreeItem nodeId="2" label="Subitem 1-1" />
      </StyledTreeItem>
      <StyledTreeItem nodeId="5" label="Item 2">
        <StyledTreeItem nodeId="10" label="Subitem 2-1" />
        <StyledTreeItem nodeId="6" label="Subitem 2-2">
          <StyledTreeItem nodeId="8" label="Subitem 2-2-1" />
        </StyledTreeItem>
      </StyledTreeItem>
    </StyledTreeView>
  );
}

The custom style applied to TreeView removes the indentation, and the one applied to StyledTreeItem removes the space assigned to an icon.

Here's a sandbox with an unintended TreeView

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!