scoped
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.
A 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.
A button can also be passed data via the data
property on ActionSheetButton
. This will populate the data
field in the return value of the onDidDismiss
method.
Action 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.
.action-sheet-group {
background: #e5e5e5;
}
.my-custom-class .action-sheet-group {
background: #e5e5e5;
}
Any of the defined CSS Custom Properties can be used to style the Action Sheet without needing to target individual elements.
Action Sheets are given a role
of dialog
. In order to align with the ARIA spec, either the aria-label
or aria-labelledby
attribute must be set.
It is strongly recommended that every Action Sheet have the header
property defined, as Ionic will automatically set aria-labelledby
to point to the header element. However, if you choose not to include a header
, an alternative is to use the htmlAttributes
property to provide a descriptive aria-label
or set a custom aria-labelledby
value.
interface ActionSheetButton<T = any> {
text?: string;
role?: 'cancel' | 'destructive' | 'selected' | string;
icon?: string;
cssClass?: string | string[];
handler?: () => boolean | void | Promise<boolean | void>;
data?: T;
}
interface ActionSheetOptions {
header?: string;
subHeader?: string;
cssClass?: string | string[];
buttons: (ActionSheetButton | string)[];
backdropDismiss?: boolean;
translucent?: boolean;
animated?: boolean;
mode?: Mode;
keyboardClose?: boolean;
id?: string;
htmlAttributes?: { [key: string]: any };
enterAnimation?: AnimationBuilder;
leaveAnimation?: AnimationBuilder;
}
Description | If true , the action sheet will animate. |
Attribute | animated |
Type | boolean |
Default | true |
Description | If true , the action sheet will be dismissed when the backdrop is clicked. |
Attribute | backdrop-dismiss |
Type | boolean |
Default | true |
Description | An array of buttons for the action sheet. |
Attribute | undefined |
Type | (string | ActionSheetButton<any>)[] |
Default | [] |
Description | 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 |
Description | Animation to use when the action sheet is presented. |
Attribute | undefined |
Type | ((baseEl: any, opts?: any) => Animation) | undefined |
Default | undefined |
Description | Title for the action sheet. |
Attribute | header |
Type | string | undefined |
Default | undefined |
Description | Additional attributes to pass to the action sheet. |
Attribute | undefined |
Type | undefined | { [key: string]: any; } |
Default | undefined |
Description | If true , the keyboard will be automatically dismissed when the overlay is presented. |
Attribute | keyboard-close |
Type | boolean |
Default | true |
Description | Animation to use when the action sheet is dismissed. |
Attribute | undefined |
Type | ((baseEl: any, opts?: any) => Animation) | undefined |
Default | undefined |
Description | The mode determines which platform styles to use. |
Attribute | mode |
Type | "ios" | "md" |
Default | undefined |
Description | Subtitle for the action sheet. |
Attribute | sub-header |
Type | string | undefined |
Default | undefined |
Description | If true , the action sheet will be translucent. Only applies when the mode is "ios" and the device supports backdrop-filter . |
Attribute | translucent |
Type | boolean |
Default | false |
Name | Description | Bubbles |
---|
ionActionSheetDidDismiss | Emitted after the alert has dismissed. | true |
ionActionSheetDidPresent | Emitted after the alert has presented. | true |
ionActionSheetWillDismiss | Emitted before the alert has dismissed. | true |
ionActionSheetWillPresent | Emitted before the alert has presented. | true |
Description | Dismiss the action sheet overlay after it has been presented. |
Signature | dismiss(data?: any, role?: string) => Promise<boolean> |
Description | Returns a promise that resolves when the action sheet did dismiss. |
Signature | onDidDismiss<T = any>() => Promise<OverlayEventDetail<T>> |
Description | Returns a promise that resolves when the action sheet will dismiss. |
Signature | onWillDismiss<T = any>() => Promise<OverlayEventDetail<T>> |
Description | Present the action sheet overlay after it has been created. |
Signature | present() => Promise<void> |
No CSS shadow parts available for this component.
Name | 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 |
No slots available for this component.