Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Styling ionic 2 toast

Tags:

Is there any way to style the text message within an ionic 2 toast?

I have tried this:

    let toast = Toast.create({
      message: "Some text on one line. <br /><br /> Some text on another line.",
      duration: 15000,
      showCloseButton: true,
      closeButtonText: 'Got it!',
      dismissOnPageChange: true
    });

    toast.onDismiss(() => {
      console.log('Dismissed toast');
    });

    this.nav.present(toast);
  }

But clearly you can't use html in the text so I am guessing the answer to my question is no?

like image 276
Bill Noble Avatar asked May 09 '16 14:05

Bill Noble


People also ask

What is toast message?

A toast provides simple feedback about an operation in a small popup. It only fills the amount of space required for the message and the current activity remains visible and interactive. Toasts automatically disappear after a timeout.


1 Answers

You must add 'cssClass: "yourCssClassName"' in your toastCtrl function.

 let toast = Toast.create({
      message: "Some text on one line. <br /><br /> Some text on another line.",
      duration: 15000,
      showCloseButton: true,
      closeButtonText: 'Got it!',
      dismissOnPageChange: true,
      cssClass: "yourCssClassName",
    });

than you can add any feature to the your css class. But your css feature went outside the default page'css. Exmp:

   page-your.page.scss.name {
     //bla bla
    }
 .yourCssClassName {
   text-align:center;
  }
like image 91
Burhan Gül Avatar answered Oct 30 '22 08:10

Burhan Gül