Material-ui: Material-UI Paper component does not recognize new line character

Created on 17 Nov 2017  路  5Comments  路  Source: mui-org/material-ui

I am passing to the Material-UI Paper component a string that contains a new line character. However, the Paper component seems to be ignoring it, as it is not starting a new line. Is this behavior intentional, or is this a bug. The code in question is below (comment.text is the string in question):

<Paper key={index} rounded={false} style={styles.paper}> 
<div>{comment.text}</div> 
<div style={{textAlign: 'right', color: grey500}}>{comment.user + ", " + comment.date}</div> 
</Paper>
question

Most helpful comment

I used: style={{whiteSpace: 'pre-line'}}

<Typography
  variant="body1"
  style={{whiteSpace: 'pre-line'}}
>
  {body}
</Typography>

Reference:
https://stackoverflow.com/questions/39325414/line-break-in-html-with-n

All 5 comments

@alexanderwhatley What is the value of comment.text? And which versions of everything are you using? The template that we provide is to help answer the questions more efficiently. 馃榿

Hey @m2mathew, sorry about that. The version of material-ui is 0.17.4, and the value of comment.text is "Hi how \n are you?"

Well, think about how the DOM would handle this. I would expect \n to render if I put that between two <div>s in an HTML file.

image

Since this isn't related to MUI explicitly, I will close this issue. Be sure to head to Stack Overflow or similar for more help implementing content within the DOM.

I used: style={{whiteSpace: 'pre-line'}}

<Typography
  variant="body1"
  style={{whiteSpace: 'pre-line'}}
>
  {body}
</Typography>

Reference:
https://stackoverflow.com/questions/39325414/line-break-in-html-with-n

It seems like it worth additional prop on the "Typography" component.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

activatedgeek picture activatedgeek  路  3Comments

ericraffin picture ericraffin  路  3Comments

sys13 picture sys13  路  3Comments

ghost picture ghost  路  3Comments

revskill10 picture revskill10  路  3Comments