Snackbar will appear a small pop-up box at the bottom of the window, they can automatically disappear after a timeout or the user touches other parts of the screen.
Only one Snackbar can be displayed on the screen at the same time. If the next Snackbar is opened before the Snackbar is closed, the next Snackbar will be added to the queue, and it will be opened after the current Snackbar is closed.
Call method mdui.snackbar(params)
That's it.
Snackbar is directly called by JavaScript, no need to write HTML layout.
There are two ways to call Snackbar:
mdui.snackbar(message, params)
mdui.snackbar(params)
The return values โโof both methods are instances of Snackbar.
Parameters required to create Snackbar:
parameter name | Types of | Defaults | Description |
---|---|---|---|
message |
string |
Snackbar text. When called by mdui.snackbar(params) , this parameter cannot be empty. |
|
timeout |
int |
4000 |
How long to hide automatically when the user does not operate, unit (milliseconds). When it is 0, it means that it will not be closed automatically. |
position |
string |
bottom |
Snackbar's location.
|
buttonText |
string |
The text of the button. | |
buttonColor |
string |
#90CAF9 |
The text color of the button, which can be a color name or a color value, such as red ใ#ffffff ใrgba(255, 255, 255, 0.3) Wait. |
closeOnButtonClick |
boolean |
true |
Whether to close the Snackbar when the button is clicked. |
closeOnOutsideClick |
boolean |
true |
Whether to close the Snackbar when clicking or touching the area outside the Snackbar. |
onClick |
function |
Callback function for clicking on Snackbar. | |
onButtonClick |
function |
The callback function when the button on the Snackbar is clicked. | |
onOpen |
function |
The callback function when Snackbar starts to open. | |
onOpened |
function |
The callback function after Snackbar is opened. | |
onClose |
function |
The callback function when Snackbar starts to close. | |
onClosed |
function |
The callback function after Snackbar is closed. |
Methods owned by the Snackbar instance:
Method name | description |
---|---|
close |
Close the Snackbar, the Snackbar will be destroyed after closing. |
mdui.snackbar({
message: 'Archived',
buttonText: 'undo',
onClick: function(){
mdui.alert('Clicked Sanckbar');
},
onButtonClick: function(){
mdui.alert('Button clicked');
},
onClose: function(){
mdui.alert('closed');
}
});
Theme color
Main color
Accent color