DedrisFrameworkDedrisFramework

← Plugins  /  Action Sheet

🗂️

Action Sheet

cordova-plugin-actionsheet
iOS Android

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.

Installation

terminal
cordova plugin add cordova-plugin-actionsheet

API

The plugin is exposed as window.plugins.actionsheet after deviceready:

MethodDescription
show(options, callback)Display the action sheet. The callback receives the 1-based index of the chosen button.
hide()Dismiss the action sheet programmatically.

Options

KeyDescription
titleOptional heading shown above the buttons.
buttonLabelsArray of strings — the main choices.
addCancelButtonWithLabelAdds a Cancel button with the given label.
addDestructiveButtonWithLabelAdds a red "destructive" button (e.g. Delete).
androidTheme / positionPlatform-specific theming and (iPad) popover anchor.

Usage example

Offer Share, Edit and a destructive Delete option:

www/js/app.js
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);
  });
}

Tips

📚 Source: the technical reference on this page is based on the cordova-plugin-actionsheet project (MIT licensed), maintained by the open-source community and listed in Ionic Native. Descriptions and examples have been rewritten in DedrisFramework's own words. This plugin is not part of the Apache Cordova core.
← Back to plugins Start a project