Materialize: different colors for different toasts

Created on 4 Mar 2016  路  14Comments  路  Source: Dogfalo/materialize

I would like to show the toast like "Saved Successfully", "Please check your entry" and so on. for each information i wanna popup toast with different colors. For successfull message, toast color wanna be green, for error it should be red and so on.

Most helpful comment

In Updated Version, It's something like:

M.toast({
html: 'Data updated Successfully',
classes: 'green darken-1 rounded'
});

All 14 comments

It's in the documentation - dialogs

Styling Toasts

Materialize.toast('I am a toast!', 3000, 'blue') 

'blue' is the class I'm applying to the toast for color


edit: few examples

HTML

  <a class="btn" onclick="Materialize.toast('I am a toast', 4000, 'blue')">Toast!</a>

jQuery

<a id="something" class="btn">Toast!</a>
$('#something').click(function(){
    Materialize.toast('I am a toast!', 3000, 'blue')
});

thanks dude. i got it. but i also need 'rounded' class along with color class. how to do????

Materialize.toast('I am a toast!', 3000, 'blue rounded') 

Like @Kail0 mentioned... It's in the documentation - dialogs

isn't in dialogs direction.

Yeah a little blurb on color should be included in the documentation. It's not there currently. Also as far as I'm aware it doesn't look like you can pass hex values into it, but I suppose that's not a feature?

I didn't understand, until I come across here, that we can customize the color of toasts.

I agree you can change colors.but how to set my custom color by HEX code like #3a4a61

in your css file, you can define a class and then set this class in JS on the toast.

I already got it thanks man.

can i use colours directly in my javascript helper class?

No that will not work

In Updated Version, It's something like:

M.toast({
html: 'Data updated Successfully',
classes: 'green darken-1 rounded'
});

In Updated Version, It's something like:

M.toast({
html: 'Data updated Successfully',
classes: 'green darken-1 rounded'
});

Perfect

How can I add border: 2px blue solid; to the toast? I want the background-color to be white while the border color to be red or green depending on the type of message

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Robouste picture Robouste  路  3Comments

onigetoc picture onigetoc  路  3Comments

serkandurusoy picture serkandurusoy  路  3Comments

djensen47 picture djensen47  路  3Comments

ruslandzhumaev picture ruslandzhumaev  路  3Comments