Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to read and show line breaks #63

Open
ardowz opened this issue May 8, 2018 · 3 comments
Open

Ability to read and show line breaks #63

ardowz opened this issue May 8, 2018 · 3 comments

Comments

@ardowz
Copy link

ardowz commented May 8, 2018

When the text includes characters like \n\r or <br/> or Text that are surrounded with <p>. It would not be converted into line breaks.

@lagroms
Copy link

lagroms commented Apr 6, 2023

I'm looking for the same feature

@tavoparra
Copy link

Need the same feature here

@JulianBristol
Copy link

JulianBristol commented May 18, 2023

Had the same issue. I used \n line breaks and CSS to fix the issue
To fix, use something like this:

import React from "react";
import TextTruncate from "react-text-truncate";
import "./styles.css";

const TruncatedText = () => {
  const content = "Your long text goes here...\nWith line breaks.";
  return (
    <div>
        <TextTruncate
          line={3}
          element="span"
          truncateText="..."
          text={content}
          containerClassName="text-truncate"
        />
    </div>
  );
};
export default TruncatedText ;

Then in your CSS,

.text-truncate {
  white-space: pre-line;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants