Skip to main content

@napacitor/action-sheet

Native action sheet plugin (corresponds to @capacitor/action-sheet).

Installation​

To use npm:

npm install @napacitor/action-sheet

To use yarn:

yarn add @napacitor/action-sheet

Sync native files:

npx nap sync

Usage​

import { ActionSheet } from '@napacitor/action-sheet';

const { index, canceled } = await ActionSheet.showActions({
title: 'Choose an action',
options: [
{ title: 'Upload' },
{ title: 'Share' },
{ title: 'Delete', style: ActionSheetButtonStyle.Destructive },
],
cancelable: true,
});
console.log(index, canceled); // 2 false / -1 true (canceled)

How It Works​

Wraps the Page.DisplayActionSheet API described in the .NET MAUI documentation, switching to the UI thread via MainThread.InvokeOnMainThreadAsync before showing the native action sheet. The returned index follows the order of the options array and is -1 when canceled. On Windows, MAUI falls back to a ContentDialog-style selection popup.

Permissions​

Android​

No additional configuration required.

iOS​

No additional configuration required.

Windows​

No additional configuration required.

API​

showActions(options)​

Shows the action sheet; when canceled, index is -1 and canceled is true.

Returns: Promise<ShowActionsResult>

ParamType
optionsShowActionsOptions

Interfaces​

ActionSheetButton​

PropTypeDescription
titlestringButton label.
styleActionSheetButtonStyleButton style. iOS-only semantics; DisplayActionSheet has no matching parameter, so the native side currently ignores it (destructive button styling requires platform code); ignored on web as well.
iconstringButton icon. Web-only; ignored on native.

ShowActionsOptions​

PropTypeDescription
titlestringAction sheet title.
messagestringMessage shown below the title. iOS-only semantics; DisplayActionSheet has no matching parameter, so the native side ignores it.
optionsActionSheetButton[]Available options. Must not be empty (at least one option with a title), otherwise INVALID_ARGUMENTS is thrown.
cancelablebooleanWhether tapping outside the sheet cancels it (default false). When true, a 'Cancel' button is provided (without it the sheet cannot be dismissed by tapping outside); canceling returns {index: -1, canceled: true}.

ShowActionsResult​

PropTypeDescription
indexnumberIndex of the clicked option (0-based); -1 when canceled.
canceledbooleanWhether the sheet was canceled.