Hi Sean and team
I love the feel of the Swal fire so I'm trying to make it a bit more customised as a standalone query (in place of the more clunky looking modals). I've checked your documentation here: https://preview.keenthemes.com/metronic/demo6/features/miscellaneous/sweetalert2.html, and here: https://preview.keenthemes.com/metronic8/demo1/documentation/general/sweetalert.html.
It doesn't appear to accept carriage returns (new lines) in the text data.
I've tried \n \r and </br>, and adding a new item in the Text array ['line 1 of text','line 2 of text']
None of these work, but I'm hopeful you can provide some guidance on a workaround.
Thanks
You can achieve line breaks in SweetAlert2 (Swal.fire) by using HTML tags inside the text or html attribute. Since \n and <br> don’t work in text, try switching to html like this:
Swal.fire({
title: "Custom Alert",
html: "Line 1 of text<br>Line 2 of text",
icon: "info"
});
Hey! SweetAlert2 is a fantastic choice for sleek and customizable alerts. Regarding your issue with new lines, you can achieve line breaks in thetext
property using template literals (backticks) or by settinghtml
instead oftext
. Try this:
Swal.fire({ title: "Custom Alert", text: `Line 1 of text Line 2 of text`, });
html
:Swal.fire({ title: "Custom Alert", html: "Line 1 of text<br>Line 2 of text", });
Hope this helps! By the way, if you're into mobile gaming, check out Cricket League MOD APK – a great resource for Cricket League fans!
Hi,
You can try to use HTML format, instead of text:
swal({ title: "hi", html: "First line<br>Second line" });
Danka!
All the best with your projects