question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How can I create a new line inside a text element?

See original GitHub issue

In the documentation example (https://konvajs.org/docs/shapes/Text.html) it shows that I can use \n to create a new line, but it doesn’t work for some reason.

      var complexText = new Konva.Text({
        x: 20,
        y: 60,
        text:
          "COMPLEX TEXT\n\nAll the world's a stage, and all the men and women merely players. They have their exits and their entrances.",
        fontSize: 18,
        fontFamily: 'Calibri',
        fill: '#555',
        width: 300,
        padding: 20,
        align: 'center'
      });

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lavrtoncommented, Sep 17, 2019
0reactions
ribas14commented, Sep 18, 2019

I need to remove the listener of the enter key to create a new line, thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Line break in HTML with '\n' - Stack Overflow
The <br> HTML element produces a line break in text (carriage-return). It is useful for writing a poem or an address, where the...
Read more >
<br>: The Line Break element - HTML - MDN Web Docs - Mozilla
The HTML element produces a line break in text (carriage-return). It is useful for writing a poem or an address, where the division...
Read more >
Add a Line Break in HTML - Tutorial - TeachUcomp, Inc.
To add a line break to your HTML code, you use the <br> tag. The <br> tag does not have an end tag....
Read more >
HTML New Line – How to Add a Line Break with the BR Tag
In this article, I'll explain what line breaks are and show you how to create them in HTML. What is a Line Break?...
Read more >
How to Create a New Line in a P Tag of HTML - Computer Hope
Most programs and online forms support the Shift + Enter keyboard shortcut. To use this shortcut, move to the text cursor to where...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found