[SalesForce] Show lightning toast message in multiple lines

I have a lightning component which I am using for quickaction and I currently show an error message which is passed from the controller as a String. The problem is, I want to show the error message in multiple lines instead of a single line. Below is the relevant code for the same:

var action2 = component.get("c.callfun");
            action2.setParams({"accId" : recId});
            action2.setCallback(this, function(response) {
            var state = response.getState();
                errMsgs = response.getReturnValue();
                var errmsg= new Array(); 
                errmsg = errMsgs.toString().split("."); 
                //alert(errmsg);
                var i;
                resultsToast.setParams({
                "title": "Error",
                    "message": errMsgs
            });

            resultsToast.fire();
            var dismissActionPanel = $A.get("e.force:closeQuickAction");
            dismissActionPanel.fire();
            });
            $A.enqueueAction(action2);

the sample error message being returned from my apex controller is "this is a test error. this is another error. this could be the last error." – basically each being separated by a full stop (".") – Hence I was trying to split the same which again didnt yield any results.

Is there any way to display these in separate lines in the toast window – possibly with a bullet point or something?

Best Answer

You can accomplish this using jquery to change the css of the toast component.

Add this line before your toast $('.forceToastManager').css('white-space', 'pre-wrap');

Then just add \n's wherever you want line breaks in your message. In your case you can replace . with \n and I believe it will work as you want.