ion-toast
A Toast is a subtle notification commonly used in modern applications. It can be used to provide feedback about an operation or to display a system message. The toast appears on top of the app's content, and can be dismissed by the app to resume user interaction with the app.
#
PositioningToasts can be positioned at the top, bottom or middle of the viewport. The position can be passed upon creation. The possible values are top
, bottom
and middle
. If the position is not specified, the toast will be displayed at the bottom of the viewport.
#
DismissingThe toast can be dismissed automatically after a specific amount of time by passing the number of milliseconds to display it in the duration
of the toast options. If a button with a role of "cancel"
is added, then that button will dismiss the toast. To dismiss the toast after creation, call the dismiss()
method on the instance.
#
Usage- ANGULAR
- JAVASCRIPT
- REACT
- STENCIL
- VUE
Developers can also use this component directly in their template:
#
Properties#
animatedDescription | If true , the toast will animate. |
Attribute | animated |
Type | boolean |
Default | true |
#
buttonsDescription | An array of buttons for the toast. |
Attribute | undefined |
Type | (string \| ToastButton)[] \| undefined |
Default | undefined |
#
colorDescription | The color to use from your application's color palette. Default options are: "primary" , "secondary" , "tertiary" , "success" , "warning" , "danger" , "light" , "medium" , and "dark" .For more information on colors, see theming. |
Attribute | color |
Type | string \| undefined |
Default | undefined |
#
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 |
#
durationDescription | How many milliseconds to wait before hiding the toast. By default, it will show until dismiss() is called. |
Attribute | duration |
Type | number |
Default | 0 |
#
enterAnimationDescription | Animation to use when the toast is presented. |
Attribute | undefined |
Type | ((baseEl: any, opts?: any) => Animation) \| undefined |
Default | undefined |
#
headerDescription | Header to be shown in the toast. |
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 | false |
#
leaveAnimationDescription | Animation to use when the toast is dismissed. |
Attribute | undefined |
Type | ((baseEl: any, opts?: any) => Animation) \| undefined |
Default | undefined |
#
messageDescription | Message to be shown in the toast. |
Attribute | message |
Type | IonicSafeString \| string \| undefined |
Default | undefined |
#
modeDescription | The mode determines which platform styles to use. |
Attribute | mode |
Type | "ios" \| "md" |
Default | undefined |
#
positionDescription | The position of the toast on the screen. |
Attribute | position |
Type | "bottom" \| "middle" \| "top" |
Default | 'bottom' |
#
translucentDescription | If true , the toast will be translucent.Only applies when the mode is "ios" and the device supportsbackdrop-filter . |
Attribute | translucent |
Type | boolean |
Default | false |
#
EventsName | Description |
---|---|
ionToastDidDismiss | Emitted after the toast has dismissed. |
ionToastDidPresent | Emitted after the toast has presented. |
ionToastWillDismiss | Emitted before the toast has dismissed. |
ionToastWillPresent | Emitted before the toast has presented. |
#
Methods#
dismissDescription | Dismiss the toast overlay after it has been presented. |
Signature | dismiss(data?: any, role?: string \| undefined) => Promise<boolean> |
#
onDidDismissDescription | Returns a promise that resolves when the toast did dismiss. |
Signature | onDidDismiss<T = any>() => Promise<OverlayEventDetail<T>> |
#
onWillDismissDescription | Returns a promise that resolves when the toast will dismiss. |
Signature | onWillDismiss<T = any>() => Promise<OverlayEventDetail<T>> |
#
presentDescription | Present the toast overlay after it has been created. |
Signature | present() => Promise<void> |
#
CSS Shadow PartsName | Description |
---|---|
button | Any button element that is displayed inside of the toast. |
container | The element that wraps all child elements. |
header | The header text of the toast. |
message | The body text of the toast. |
#
CSS Custom PropertiesName | Description |
---|---|
--background | Background of the toast |
--border-color | Border color of the toast |
--border-radius | Border radius of the toast |
--border-style | Border style of the toast |
--border-width | Border width of the toast |
--box-shadow | Box shadow of the toast |
--button-color | Color of the button text |
--color | Color of the toast text |
--end | Position from the right if direction is left-to-right, and from the left if direction is right-to-left |
--height | Height of the toast |
--max-height | Maximum height of the toast |
--max-width | Maximum width of the toast |
--min-height | Minimum height of the toast |
--min-width | Minimum width of the toast |
--start | Position from the left if direction is left-to-right, and from the right if direction is right-to-left |
--white-space | White space of the toast message |
--width | Width of the toast |