'How to style a Material Ui component
I am trying to apply a condition margin to a component. This function receive prop. When the prop.children has a value I want to change the margin. I marked the section I have issues with with //issue here
const StyledTreeItem = styled((props) => (
<TreeItem {...props} TransitionComponent={TransitionComponent} />
))(({ theme }) => ({
[`& .${treeItemClasses.iconContainer}`]: {
"& .close": {
opacity: 0.3,
},
},
[`& .${treeItemClasses.group}`]: {
marginLeft: 15,
paddingLeft: 18,
borderLeft: `1px dashed ${alpha(theme.palette.text.primary, 0.4)}`,
},
[`& .${treeItemClasses.label}`]: {
// issue here
marginLeft: props.children.length > 0 && 14,
},
}));
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
