Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multiline with <ListItemText>

enter image description here

CODEPEN: https://codesandbox.io/s/94lw648lmo?fontsize=14

I have been using Material-ui with react.

I'm trying to make a list that contains long text.

When long text is given text is shown like the picture but, I want multiline text.

Here is my code snippet of it.

<List>
  {this.props.novels.map((novel, index) => (
  <ListItem alignItems="flex-start" key={index} role={undefined}>
    <ListItemText primary={<span>{novel.text}</span>} />
  <ListItemSecondaryAction>
    <Button>
      <ThumbUp />
    </Button>
    <span>{novel.like}</span>
    <Button>
      <ThumbDown />
    </Button>
    <span>{novel.dislike}</span>
  </ListItemSecondaryAction>
  </ListItem>
))}
</List>

Please let me know if you need more info.

Thanks.

like image 275
JillAndMe Avatar asked Apr 11 '19 09:04

JillAndMe


2 Answers

Accepted answer did not work for me, here is what worked:

<ListItemText 
    primary={tooLongTitle} 
    primaryTypographyProps={{ style: { whiteSpace: "normal" } }} />
like image 185
Clément Prévost Avatar answered Oct 28 '22 06:10

Clément Prévost


you can add the following CSS to your cell:

word-wrap: break-word;

Hope it helps

like image 36
AlbertSabate Avatar answered Oct 28 '22 05:10

AlbertSabate