cordova-plugin-toast-smooth
v1.0.0
Published
This plugin allows you to show a Toast. A Toast is a little non intrusive buttonless popup which automatically disappears.
Maintainers
Readme
cordova-plugin-toast-smooth
A simple Cordova plugin to show customizable toast messages with flexible styling and positioning on Android.
Platform Support
- Android only
Installation
cordova plugin add cordova-plugin-toast-smoothUsage
Show a toast with options object
cordova.plugins.toast.showWithOptions({
message: "Hello World!",
duration: "short", // "short" | "long" | milliseconds as number or string
position: "bottom", // "top" | "center" | "bottom"
addPixelsY: 0, // vertical offset in pixels (positive or negative)
backgroundColor: "#333333",
textColor: "#ffffff",
textSize: 16,
opacity: 0.9,
cornerRadius: 20,
horizontalPadding: 24,
verticalPadding: 16,
useIcon: false
},
() => { console.log("Toast shown"); },
(err) => { console.error("Toast error:", err); });Show a simple toast with message, duration, and position
cordova.plugins.toast.show("Hello World!", "long", "center");Hide the toast manually
cordova.plugins.toast.hide();Options Builder
Use the builder pattern to construct options step-by-step:
const options = cordova.plugins.toast.optionsBuilder()
.withMessage("Hello Builder!")
.withDuration("long")
.withPosition("center")
.withBackgroundColor("#222222")
.withTextColor("#ffeecc")
.withTextSize(18)
.withOpacity(0.8)
.withCornerRadius(12)
.withPadding(30, 20)
.withIcon(true)
.build();
cordova.plugins.toast.showWithOptions(options);Convenience Methods
These shorthand methods show toast with predefined duration and position:
showShortTop(message)showShortCenter(message)showShortBottom(message)showLongTop(message)showLongCenter(message)showLongBottom(message)
Example:
cordova.plugins.toast.showLongBottom("Long toast at bottom");Notes
- The toast will automatically disappear after the specified duration.
useIcon: truedisplays the app icon to the left of the message.addPixelsYallows fine vertical adjustment of the toast position.- The toast background uses rounded corners and customizable opacity.
License
MIT
