How can I style the text within an ionic alert?

So I have some information that I want to display, but “\n” doesn’t break the line, nor can I change the font size or color. I understand there is a cssClass option, however the docs do a very poor job of explaining that–I don’t even know if it’s applicable for my needs.

Try setting it and seeing what happens.

  popAlert(): void {
    let alert = this._alerts.create({
      message: "hello\nworld",
      cssClass: 'foo',

<button ion-button (click)="popAlert()">pop alert</button>

// App Global Sass

.foo .alert-message {
  white-space: pre;

That works! Why does it have to be in the global sass though?

Because in the DOM, the alert is outside the current page, so it wouldn’t get caught in the page’s SCSS, which is limited to the selector assigned to that page. You can track these sorts of things down by using the Elements feature of Chrome’s Developer Tools (I’m sure there are other ways as well, but that’s what I use).

1 Like

If you look at bottom of this page (, you will see a whole slew of SASS variables you can define as well.

Interesting… Is there also a way that I can left align the text? On iOS it centers the text even with text-align: left;. Also, are there ways that I can bold certain words?


Did you ever find answers to your questions re: bolding certain words etc. The documentation on this stuff is scant.

1 Like

To Bold the text just enclose your text(may be title or sub title) inside Tags. To go to next line use

Did you get any answer to align the text to left.