Building apps at a large company? Check out Ionic Enterprise

Action Sheet

Improve this doc

The ActionSheet plugin shows a native list of options the user can choose from.

Requires Cordova plugin: cordova-plugin-actionsheet. For more info, please see the ActionSheet plugin docs.

Repo: https://github.com/EddyVerbruggen/cordova-plugin-actionsheet

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-plugin-actionsheet
    $ npm install --save @ionic-native/action-sheet
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { ActionSheet, ActionSheetOptions } from '@ionic-native/action-sheet';

constructor(private actionSheet: ActionSheet) { }

...


let buttonLabels = ['Share via Facebook', 'Share via Twitter'];

const options: ActionSheetOptions = {
  title: 'What do you want with this image?',
  subtitle: 'Choose an action',
  buttonLabels: buttonLabels,
  addCancelButtonWithLabel: 'Cancel',
  addDestructiveButtonWithLabel: 'Delete',
  androidTheme: this.actionSheet.ANDROID_THEMES.THEME_HOLO_DARK,
  destructiveButtonLast: true
};

this.actionSheet.show(options).then((buttonIndex: number) => {
  console.log('Button pressed: ' + buttonIndex);
});

Instance Members

ANDROID_THEMES

Convenience property to select an Android theme value

show(options)

Show a native ActionSheet component. See below for options.

Param Type Details
options ActionSheetOptions

Options See table below

Returns: Promise<any> Returns a Promise that resolves with the index of the button pressed (1 based, so 1, 2, 3, etc.)

hide()

Progamtically hide the native ActionSheet

Returns: Promise<any> Returns a Promise that resolves when the actionsheet is closed

ActionSheetOptions

Param Type Details
buttonLabels string[]

The labels for the buttons. Uses the index x

title string

The title for the actionsheet

(optional)
subtitle string

The subtitle for the actionsheet (IOS only)

(optional)
androidTheme number

Theme to be used on Android

(optional)
androidEnableCancelButton boolean

Enable a cancel on Android

(optional)
winphoneEnableCancelButton boolean

Enable a cancel on Windows Phone

(optional)
addCancelButtonWithLabel string

Add a cancel button with text

(optional)
addDestructiveButtonWithLabel string

Add a destructive button with text

(optional)
position number[]

On an iPad, set the X,Y position

(optional)
destructiveButtonLast boolean

Choose if destructive button will be the last

(optional)

API

Native

General