← Plugins / Action Sheet
This community plugin shows a native action sheet — the slide-up menu of choices iOS and Android use for contextual actions like "Share", "Edit" or "Delete". You pass a list of button labels and get back the index of the one the user tapped.
cordova plugin add cordova-plugin-actionsheet
The plugin is exposed as window.plugins.actionsheet after deviceready:
| Method | Description |
|---|---|
show(options, callback) | Display the action sheet. The callback receives the 1-based index of the chosen button. |
hide() | Dismiss the action sheet programmatically. |
| Key | Description |
|---|---|
title | Optional heading shown above the buttons. |
buttonLabels | Array of strings — the main choices. |
addCancelButtonWithLabel | Adds a Cancel button with the given label. |
addDestructiveButtonWithLabel | Adds a red "destructive" button (e.g. Delete). |
androidTheme / position | Platform-specific theming and (iPad) popover anchor. |
Offer Share, Edit and a destructive Delete option:
function openMenu() {
var options = {
title: "What would you like to do?",
buttonLabels: ["Share", "Edit"],
addCancelButtonWithLabel: "Cancel",
addDestructiveButtonWithLabel: "Delete"
};
window.plugins.actionsheet.show(options, function (index) {
console.log("Tapped button " + index);
});
}
position so the popover points at the control that opened it.