Materialize provides an easy way for you to send unobtrusive alerts to your users through toasts. These toasts are also placed and sized responsively, try it out by clicking the button below on different device sizes.

Basic

To do this, call the Materialize.toast() function programatically in JavaScript.
// Materialize.toast(message, displayLength, className, completeCallback);
Materialize.toast('I am a toast!', 4000) // 4000 is the duration of the toast
One way to add this into your application is to add this as an onclick event to a button
<a class="btn" onclick="Materialize.toast('I am a toast', 4000)">Toast!</a>

Custom HTML

You can pass in an HTML String as the first argument as well. Take a look at the example below, where we pass in text as well as a flat button. If you call an external function instead of in-line JavaScript, you will not need to escape quotation marks.

Toast with Action

<a class="waves-effect waves-light btn" onclick="Materialize.toast('<span>Item Deleted</span><a class="btn-flat yellow-text" href="#!"">Undo<a>', 5000)">Toast!</a>

Callback

You can have the toast callback a function when it has been dismissed.

Toast!

<a class="btn" onclick="Materialize.toast('I am a toast', 4000,'',function(){alert('Your toast was dismissed')})">Toast!</a>

Styling Toasts

We've added the ability to customize your toasts easily. You can pass in classes as an optional parameter into the toast function. We've added a rounded class for you, but you can create your own CSS classes and apply them to toasts. Checkout out our full example below.

Round Toast!

Materialize.toast('I am a toast!', 3000, 'rounded') // 'rounded' is the class I'm applying to the toast
Online
Felecia Castro
Felecia Castro
Lorem status
Max Brooks
Max Brooks
Lorem status
Patsy Griffin
Patsy Griffin
Lorem status
Chloe Morgan
Chloe Morgan
Lorem status
Vernon Garrett
Vernon Garrett
Lorem status
Greg Mcdonalid
Greg Mcdonalid
Lorem status
Christian Jackson
Christian Jackson
Lorem status
Offline
Willie Kelly
Willie Kelly
Lorem status
Jenny Phillips
Jenny Phillips
Lorem status
Darren Cunningham
Darren Cunningham
Lorem status
Sandra Cole
Sandra Cole
Lorem status
Monday, Feb 23, 8:23 pm
Hi, Felicia.
How are you?
John DoeHi! I am good!
Glad to see you :)
This long text is intended to show how the chat will display it.
John DoeAlso, we will send the longest word to show how it will fit in the chat window: Pneumonoultramicroscopicsilicovolcanoconiosis
Friday, Mar 10, 5:07 pm
Hi again!
John DoeHi! Glad to see you.
I want to add you in my Facebook.
Can you give me your page?
John DoeI do not use Facebook. But you can follow me in Twitter.
It's good idea!
John DoeYou can find me here - https://twitter.com/nkdevv