t4t5 / sweetalert

A beautiful replacement for JavaScript's "alert"
https://sweetalert.js.org
MIT License
22.4k stars 2.84k forks source link

Support for new lines in message? #374

Closed koullislp closed 7 years ago

koullislp commented 9 years ago

What the title says, please??

djm61 commented 9 years ago

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

dann1609 commented 6 years ago

How I do this?

FALL1N1 commented 6 years ago

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

Eugene-Melbourne commented 6 years ago

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

themightystephen commented 5 years ago

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"
});
paokodo commented 5 years ago

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

wafa-code commented 4 years ago

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");

Matheus-Ribeiro95 commented 4 years ago

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

EDIT: and thanks @themightystephen

CaptRango commented 3 years ago

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