admin管理员组文章数量:1431010
Sorry if this has been asked, I looked and couldn't find the answer!
I have a Material UI listview that has a set width (it's in a sidebar). I am trying to render the titles of some options, and the Primary text of ListItemText is wrapping past its container. Why is it not simply extending the container's height and going multi-line?
Thanks so much in advance!
return (
<ListItem
key={network._id}
selected={userwork && userwork._id === network._id}
>
<ListItemText
primary={network.name}
sx={{ maxWidth: '100%' }}
/>
<IconButton>
<DoubleArrowIcon />
</IconButton>
</ListItem>
);
Sorry if this has been asked, I looked and couldn't find the answer!
I have a Material UI listview that has a set width (it's in a sidebar). I am trying to render the titles of some options, and the Primary text of ListItemText is wrapping past its container. Why is it not simply extending the container's height and going multi-line?
Thanks so much in advance!
return (
<ListItem
key={network._id}
selected={userwork && userwork._id === network._id}
>
<ListItemText
primary={network.name}
sx={{ maxWidth: '100%' }}
/>
<IconButton>
<DoubleArrowIcon />
</IconButton>
</ListItem>
);
Share
Improve this question
asked Dec 22, 2021 at 1:43
Julian DurantiniJulian Durantini
1291 silver badge6 bronze badges
2
-
1
try to give class a style like
word-wrap:break-word;
– Monika Virmani Commented Dec 22, 2021 at 11:44 - I added that to both the ListItem and the ListItemText with no success. – Julian Durantini Commented Dec 22, 2021 at 22:28
2 Answers
Reset to default 3All,
If you have my problem, here is what worked for me:
<ListItemText
primary={tooLongTitle}
primaryTypographyProps={{ style: { whiteSpace: "normal" } }} />
Credit: multiline with <ListItemText>
Easy
<ListItemText primary="a title" primaryTypographyProps={{ noWrap: true }} />
本文标签: javascriptMaterial UI List Item Text Primary Text OverflowStack Overflow
版权声明:本文标题:javascript - Material UI List Item Text: Primary Text Overflow - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745547129a2662757.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论