ion-action-sheet
An Action Sheet is a dialog that displays a set of options. It appears on top of the app's content, and must be manually dismissed by the user before they can resume interaction with the app. Destructive options are made obvious in ios
mode. There are multiple ways to dismiss the action sheet, including tapping the backdrop or hitting the escape key on desktop.
#
ButtonsA button's role
property can either be destructive
or cancel
. Buttons without a role property will have the default look for the platform. Buttons with the cancel
role will always load as the bottom button, no matter where they are in the array. All other buttons will be displayed in the order they have been added to the buttons
array. Note: We recommend that destructive
buttons are always the first button in the array, making them the top button. Additionally, if the action sheet is dismissed by tapping the backdrop, then it will fire the handler from the button with the cancel role.
#
CustomizationAction Sheet uses scoped encapsulation, which means it will automatically scope its CSS by appending each of the styles with an additional class at runtime. Overriding scoped selectors in CSS requires a higher specificity selector.
We recommend passing a custom class to cssClass
in the create
method and using that to add custom styles to the host and inner elements. This property can also accept multiple classes separated by spaces. View the Usage section for an example of how to pass a class using cssClass
.
Any of the defined CSS Custom Properties can be used to style the Action Sheet without needing to target individual elements:
If you are building an Ionic Angular app, the styles need to be added to a global stylesheet file. Read Style Placement in the Angular section below for more information.
#
Usage- ANGULAR
- JAVASCRIPT
- REACT
- STENCIL
- VUE
#
Style PlacementIn Angular, the CSS of a specific page is scoped only to elements of that page. Even though the Action Sheet can be presented from within a page, the ion-action-sheet
element is appended outside of the current page. This means that any custom styles need to go in a global stylesheet file. In an Ionic Angular starter this can be the src/global.scss
file or you can register a new global style file by adding to the styles
build option in angular.json
.
Developers can also use this component directly in their template:
#
Properties#
animatedDescription | If true , the action sheet will animate. |
Attribute | animated |
Type | boolean |
Default | true |
#
backdropDismissDescription | If true , the action sheet will be dismissed when the backdrop is clicked. |
Attribute | backdrop-dismiss |
Type | boolean |
Default | true |
#
buttonsDescription | An array of buttons for the action sheet. |
Attribute | undefined |
Type | (string \| ActionSheetButton)[] |
Default | [] |
#
cssClassDescription | Additional classes to apply for custom CSS. If multiple classes are provided they should be separated by spaces. |
Attribute | css-class |
Type | string \| string[] \| undefined |
Default | undefined |
#
enterAnimationDescription | Animation to use when the action sheet is presented. |
Attribute | undefined |
Type | ((baseEl: any, opts?: any) => Animation) \| undefined |
Default | undefined |
#
headerDescription | Title for the action sheet. |
Attribute | header |
Type | string \| undefined |
Default | undefined |
#
keyboardCloseDescription | If true , the keyboard will be automatically dismissed when the overlay is presented. |
Attribute | keyboard-close |
Type | boolean |
Default | true |
#
leaveAnimationDescription | Animation to use when the action sheet is dismissed. |
Attribute | undefined |
Type | ((baseEl: any, opts?: any) => Animation) \| undefined |
Default | undefined |
#
modeDescription | The mode determines which platform styles to use. |
Attribute | mode |
Type | "ios" \| "md" |
Default | undefined |
#
subHeaderDescription | Subtitle for the action sheet. |
Attribute | sub-header |
Type | string \| undefined |
Default | undefined |
#
translucentDescription | If true , the action sheet will be translucent.Only applies when the mode is "ios" and the device supportsbackdrop-filter . |
Attribute | translucent |
Type | boolean |
Default | false |
#
EventsName | Description |
---|---|
ionActionSheetDidDismiss | Emitted after the alert has dismissed. |
ionActionSheetDidPresent | Emitted after the alert has presented. |
ionActionSheetWillDismiss | Emitted before the alert has dismissed. |
ionActionSheetWillPresent | Emitted before the alert has presented. |
#
Methods#
dismissDescription | Dismiss the action sheet overlay after it has been presented. |
Signature | dismiss(data?: any, role?: string \| undefined) => Promise<boolean> |
#
onDidDismissDescription | Returns a promise that resolves when the action sheet did dismiss. |
Signature | onDidDismiss<T = any>() => Promise<OverlayEventDetail<T>> |
#
onWillDismissDescription | Returns a promise that resolves when the action sheet will dismiss. |
Signature | onWillDismiss<T = any>() => Promise<OverlayEventDetail<T>> |
#
presentDescription | Present the action sheet overlay after it has been created. |
Signature | present() => Promise<void> |
#
CSS Custom PropertiesName | Description |
---|---|
--backdrop-opacity | Opacity of the backdrop |
--background | Background of the action sheet group |
--button-background | Background of the action sheet button |
--button-background-activated | Background of the action sheet button when pressed. Note: setting this will interfere with the Material Design ripple. |
--button-background-activated-opacity | Opacity of the action sheet button background when pressed |
--button-background-focused | Background of the action sheet button when tabbed to |
--button-background-focused-opacity | Opacity of the action sheet button background when tabbed to |
--button-background-hover | Background of the action sheet button on hover |
--button-background-hover-opacity | Opacity of the action sheet button background on hover |
--button-background-selected | Background of the selected action sheet button |
--button-background-selected-opacity | Opacity of the selected action sheet button background |
--button-color | Color of the action sheet button |
--button-color-activated | Color of the action sheet button when pressed |
--button-color-focused | Color of the action sheet button when tabbed to |
--button-color-hover | Color of the action sheet button on hover |
--button-color-selected | Color of the selected action sheet button |
--color | Color of the action sheet text |
--height | height of the action sheet |
--max-height | Maximum height of the action sheet |
--max-width | Maximum width of the action sheet |
--min-height | Minimum height of the action sheet |
--min-width | Minimum width of the action sheet |
--width | Width of the action sheet |