← Plugins / Toast
This community plugin shows a native "toast" — a small, non-blocking message that fades away on its own. It's the quickest way to confirm an action ("Saved!") without interrupting the user with a dialog they have to dismiss.
cordova plugin add cordova-plugin-x-toast
The plugin is exposed as window.plugins.toast after deviceready:
| Method | Description |
|---|---|
show(message, duration, position, success, error) | The flexible form. duration is "short" or "long"; position is "top", "center" or "bottom". |
showShortTop / showShortCenter / showShortBottom | Shortcuts for a brief toast at a fixed position. |
showLongTop / showLongCenter / showLongBottom | Shortcuts for a longer-lasting toast. |
showWithOptions(options, success, error) | Full control via an options object (message, duration, position, styling, addPixelsY). |
hide() | Dismiss the current toast immediately. |
Confirm a save with a short toast near the bottom of the screen:
function onSaved() {
window.plugins.toast.showShortBottom("Saved!");
}
function onError() {
window.plugins.toast.show("Something went wrong", "long", "center");
}
window.plugins.toast first.