Sweetalert: Support for new lines in message?

Created on 3 Jun 2015  ·  9Comments  ·  Source: t4t5/sweetalert

What the title says, please??

Most helpful comment

It works if you set the html property to the actual html itself (i.e. get rid of the text property and set the html property to the html content), e.g.

$swal({
  title: "My title",
  type: "error",
  html: "My text with<br />html included"
});

All 9 comments

If you set the html property to true, then you can use line breaks --> the <br/> tag.

How I do this?

swal({ html: true, title: 'hi', text: 'te<br>st' });
doesn't seem to work for me

p.s i used pr https://github.com/t4t5/sweetalert/pull/772 for much simplified usage, everything is ok now

How should I set html property to true? what is the order of html property and why is it not documented? Thank you.

It works if you set the html property to the actual html itself (i.e. get rid of the text property and set the html property to the html content), e.g.

$swal({
  title: "My title",
  type: "error",
  html: "My text with<br />html included"
});

It works for me, use \n
swal("Oops", "Line 1.\n line2.", "error");

it works just in part of text like this :
swal("Oops", "Line 1.\n line2.", "error");
but if you want to make it in part of title .. it dosn't work :
swal("Oops\nOops", "Line 1", "error");

sorry, but in my opnion doesnt make sense use multiple lines in title (and following a good design spec).

EDIT: and thanks @themightystephen

swal({ buttons: ["Wait ", "Add Details"], html: true, text: "Text one .\n Text 2.\n Text 3." })
Here is the solution. Works perfectly in react. Enjoy

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fracz picture fracz  ·  4Comments

rapeflower picture rapeflower  ·  4Comments

vmitchell85 picture vmitchell85  ·  6Comments

waldyrious picture waldyrious  ·  5Comments

girishbr picture girishbr  ·  5Comments