shadow Contents 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.
Toasts 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.
The 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.
An icon can be added next to the content inside of the toast. In general, icons in toasts should be used to add additional style or context, not to grab the user's attention or elevate the priority of the toast. If you wish to convey a higher priority message to the user or guarantee a response, we recommend using an Alert  instead.
interface   ToastButton   {   text ? :   string ;   icon ? :   string ;   side ? :   'start'   |   'end' ;   role ? :   'cancel'   |   string ;   cssClass ? :   string   |   string [ ] ;   handler ? :   ( )   =>   boolean   |   void   |   Promise < boolean   |   void > ; } Copy interface   ToastOptions   {   header ? :   string ;   message ? :   string   |   IonicSafeString ;   cssClass ? :   string   |   string [ ] ;   duration ? :   number ;   buttons ? :   ( ToastButton   |   string ) [ ] ;   position ? :   'top'   |   'bottom'   |   'middle' ;   translucent ? :   boolean ;   animated ? :   boolean ;   icon ? :   string ;   htmlAttributes ? :   ToastAttributes ;   color ? :   Color ;   mode ? :   Mode ;   keyboardClose ? :   boolean ;   id ? :   string ;   enterAnimation ? :   AnimationBuilder ;   leaveAnimation ? :   AnimationBuilder ; } Copy interface   ToastAttributes   extends   JSXBase . HTMLAttributes < HTMLElement >   { } Copy Toasts are intended to be subtle notifications and are not intended to interrupt the user. User interaction should not be required to dismiss the toast. As a result, focus is not automatically moved to a toast when one is presented.
ion-toast has aria-live="polite" and aria-atomic="true" set by default.
aria-live causes screen readers to announce the content of the toast when it is presented. However, since the attribute is set to 'polite', screen readers generally do not interrupt the current task. Developers can customize this behavior by using the htmlAttributes property to set aria-live to 'assertive'. This will cause screen readers to immediately notify the user when a toast is presented, potentially interrupting any previous updates.
aria-atomic="true" is set to ensure that the entire toast is announced as a single unit. This is useful when dynamically updating the content of the toast as it prevents screen readers from announcing only the content that has changed. 
While this is not a complete list, here are some guidelines to follow when using toasts.
Do not require user interaction to dismiss toasts. For example, having a "Dismiss" button in the toast is fine, but the toast should also automatically dismiss on its own after a timeout period. If you need user interaction for a notification, consider using ion-alert  instead.
Avoid opening multiple toasts in quick succession. If aria-live is set to 'assertive', screen readers may interrupt the reading of the current task to announce the new toast, causing the context of the previous toast to be lost.
For toasts with long messages, consider adjusting the duration property to allow users enough time to read the content of the toast.
Angular Javascript React Stencil Vue import   {   Component   }   from   '@angular/core' ; import   {   ToastController   }   from   '@ionic/angular' ; @ Component ( {   selector :   'toast-example' ,   templateUrl :   'toast-example.html' ,   styleUrls :   [ './toast-example.css' ] , } ) export   class   ToastExample   {    constructor ( public  toastController :   ToastController )   { }    async   presentToast ( )   {      const  toast  =   await   this . toastController . create ( {       message :   'Your settings have been saved.' ,       duration :   2000      } ) ;     toast . present ( ) ;    }    async   presentToastWithOptions ( )   {      const  toast  =   await   this . toastController . create ( {       header :   'Toast header' ,       message :   'Click to Close' ,       icon :   'information-circle' ,       position :   'top' ,       buttons :   [          {           side :   'start' ,           icon :   'star' ,           text :   'Favorite' ,            handler :   ( )   =>   {              console . log ( 'Favorite clicked' ) ;            }          } ,   {           text :   'Done' ,           role :   'cancel' ,            handler :   ( )   =>   {              console . log ( 'Cancel clicked' ) ;            }          }        ]      } ) ;      await  toast . present ( ) ;      const   {  role  }   =   await  toast . onDidDismiss ( ) ;      console . log ( 'onDidDismiss resolved with role' ,  role ) ;    } } Copy async   function   presentToast ( )   {    const  toast  =   document . createElement ( 'ion-toast' ) ;   toast . message   =   'Your settings have been saved.' ;   toast . duration   =   2000 ;    document . body . appendChild ( toast ) ;    return  toast . present ( ) ; } async   function   presentToastWithOptions ( )   {    const  toast  =   document . createElement ( 'ion-toast' ) ;   toast . header   =   'Toast header' ;   toast . message   =   'Click to Close' ;   toast . icon   =   'information-circle' ,   toast . position   =   'top' ;   toast . buttons   =   [      {       side :   'start' ,       icon :   'star' ,       text :   'Favorite' ,        handler :   ( )   =>   {          console . log ( 'Favorite clicked' ) ;        }      } ,   {       text :   'Done' ,       role :   'cancel' ,        handler :   ( )   =>   {          console . log ( 'Cancel clicked' ) ;        }      }    ] ;    document . body . appendChild ( toast ) ;    await  toast . present ( ) ;    const   {  role  }   =   await  toast . onDidDismiss ( ) ;    console . log ( 'onDidDismiss resolved with role' ,  role ) ; } Copy import   React   from   'react' ; import   {   IonButton ,   IonContent ,   IonPage ,  useIonToast  }   from   '@ionic/react' ; const   ToastExample :   React . FC   =   ( )   =>   {    const   [ present ,  dismiss ]   =   useIonToast ( ) ;    return   (      < IonPage >        < IonContent >          < IonButton            expand = " block "            onClick = { ( )   =>              present ( {               buttons :   [ {  text :   'hide' ,   handler :   ( )   =>   dismiss ( )   } ] ,               message :   'toast from hook, click hide to dismiss' ,                onDidDismiss :   ( )   =>   console . log ( 'dismissed' ) ,                onWillDismiss :   ( )   =>   console . log ( 'will dismiss' ) ,              } )            }          >            Show   Toast          </ IonButton >          < IonButton            expand = " block "            onClick = { ( )   =>   present ( 'hello from hook' ,   3000 ) }          >            Show   Toast  using params ,  closes  in   3  secs          </ IonButton >          < IonButton   expand = " block "   onClick = { dismiss } >            Hide   Toast          </ IonButton >        </ IonContent >      </ IonPage >    ) ; } ; Copy import   React ,   {  useState  }   from   'react' ; import   {   IonToast ,   IonContent ,   IonButton   }   from   '@ionic/react' ; import   {  informationCircle  }   from   'ionicons/icons' ; export   const   ToastExample :   React . FC   =   ( )   =>   {    const   [ showToast1 ,  setShowToast1 ]   =   useState ( false ) ;    const   [ showToast2 ,  setShowToast2 ]   =   useState ( false ) ;    return   (      < IonContent >        < IonButton   onClick = { ( )   =>   setShowToast1 ( true ) }   expand = " block " > Show   Toast   1 </ IonButton >        < IonButton   onClick = { ( )   =>   setShowToast2 ( true ) }   expand = " block " > Show   Toast   2 </ IonButton >        < IonToast          isOpen = { showToast1 }          onDidDismiss = { ( )   =>   setShowToast1 ( false ) }          message = " Your settings have been saved. "          duration = { 200 }        />        < IonToast          isOpen = { showToast2 }          onDidDismiss = { ( )   =>   setShowToast2 ( false ) }          message = " Click to Close "          icon = { informationCircle }          position = " top "          buttons = { [            {             side :   'start' ,             icon :   'star' ,             text :   'Favorite' ,              handler :   ( )   =>   {                console . log ( 'Favorite clicked' ) ;              }            } ,            {             text :   'Done' ,             role :   'cancel' ,              handler :   ( )   =>   {                console . log ( 'Cancel clicked' ) ;              }            }          ] }        />      </ IonContent >    ) ; } ; Copy import   {   Component ,  h  }   from   '@stencil/core' ; import   {  toastController  }   from   '@ionic/core' ; @ Component ( {   tag :   'toast-example' ,   styleUrl :   'toast-example.css' } ) export   class   ToastExample   {    async   presentToast ( )   {      const  toast  =   await  toastController . create ( {       message :   'Your settings have been saved.' ,       duration :   2000      } ) ;     toast . present ( ) ;    }    async   presentToastWithOptions ( )   {      const  toast  =   await  toastController . create ( {       header :   'Toast header' ,       message :   'Click to Close' ,       icon :   'information-circle' ,       position :   'top' ,       buttons :   [          {           side :   'start' ,           icon :   'star' ,           text :   'Favorite' ,            handler :   ( )   =>   {              console . log ( 'Favorite clicked' ) ;            }          } ,   {           text :   'Done' ,           role :   'cancel' ,            handler :   ( )   =>   {              console . log ( 'Cancel clicked' ) ;            }          }        ]      } ) ;      await  toast . present ( ) ;      const   {  role  }   =   await  toast . onDidDismiss ( ) ;      console . log ( 'onDidDismiss resolved with role' ,  role ) ;    }    render ( )   {      return   [        < ion-content >          < ion-button   onClick = { ( )   =>   this . presentToast ( ) } > Present   Toast </ ion-button >          < ion-button   onClick = { ( )   =>   this . presentToastWithOptions ( ) } > Present   Toast :   Options </ ion-button >        </ ion-content >      ] ;    } } Copy < template >    < ion-page >      < ion-content   class = " ion-padding " >        < ion-button   @click = " openToast " > Open Toast </ ion-button >        < ion-button   @click = " openToastOptions " > Open Toast: Options </ ion-button >      </ ion-content >    </ ion-page > </ template > < script > import   {   IonButton ,   IonContent ,   IonPage ,  toastController  }   from   '@ionic/vue' ; import   {  informationCircle  }   from   'ionicons/icons' ; export   default   {   components :   {   IonButton ,   IonContent ,   IonPage   } ,   methods :   {      async   openToast ( )   {        const  toast  =   await  toastController          . create ( {           message :   'Your settings have been saved.' ,           duration :   2000          } )        return  toast . present ( ) ;      } ,      async   openToastOptions ( )   {        const  toast  =   await  toastController          . create ( {           header :   'Toast header' ,           message :   'Click to Close' ,           icon :  informationCircle ,           position :   'top' ,           buttons :   [              {               side :   'start' ,               icon :   'star' ,               text :   'Favorite' ,                handler :   ( )   =>   {                  console . log ( 'Favorite clicked' ) ;                }              } ,   {               text :   'Done' ,               role :   'cancel' ,                handler :   ( )   =>   {                  console . log ( 'Cancel clicked' ) ;                }              }            ]          } )        await  toast . present ( ) ;        const   {  role  }   =   await  toast . onDidDismiss ( ) ;        console . log ( 'onDidDismiss resolved with role' ,  role ) ;      } ,    } , } </ script > Copy Developers can also use this component directly in their template:
< template >    < ion-button   @click = " setOpen(true) " > Show Toast </ ion-button >    < ion-toast      :is-open = " isOpenRef "      message = " Your settings have been saved. "      :duration = " 2000 "      @didDismiss = " setOpen(false) "    >    </ ion-toast > </ template > < script > import   {   IonToast ,   IonButton   }   from   '@ionic/vue' ; import   {  defineComponent ,  ref  }   from   'vue' ; export   default   defineComponent ( {   components :   {   IonToast ,   IonButton   } ,    setup ( )   {      const  isOpenRef  =   ref ( false ) ;      const   setOpen   =   ( state :  boolean )   =>  isOpenRef . value   =  state ;      return   {  isOpenRef ,  setOpen  }    } } ) ; </ script > Copy Description If true, the toast will animate. Attribute animatedType booleanDefault true
Description An array of buttons for the toast. Attribute undefinedType (string ๏ฝ ToastButton)[] ๏ฝ undefinedDefault undefined
Description The color to use from your application's color palette."primary", "secondary", "tertiary", "success", "warning", "danger", "light", "medium", and "dark".theming . Attribute colorType string ๏ฝ undefinedDefault undefined
Description Additional classes to apply for custom CSS. If multiple classes are Attribute css-classType string ๏ฝ string[] ๏ฝ undefinedDefault undefined
Description How many milliseconds to wait before hiding the toast. By default, it will showdismiss() is called. Attribute durationType numberDefault 0
Description Animation to use when the toast is presented. Attribute undefinedType ((baseEl: any, opts?: any) => Animation) ๏ฝ undefinedDefault undefined
Description Header to be shown in the toast. Attribute headerType string ๏ฝ undefinedDefault undefined
Description Additional attributes to pass to the toast. Attribute undefinedType ToastAttributes ๏ฝ undefinedDefault undefined
Description The name of the icon to display, or the path to a valid SVG file. See ion-icon.https://ionic.io/ionicons  Attribute iconType string ๏ฝ undefinedDefault undefined
Description If true, the keyboard will be automatically dismissed when the overlay is presented. Attribute keyboard-closeType booleanDefault false
Description Animation to use when the toast is dismissed. Attribute undefinedType ((baseEl: any, opts?: any) => Animation) ๏ฝ undefinedDefault undefined
Description Message to be shown in the toast. Attribute messageType IonicSafeString ๏ฝ string ๏ฝ undefinedDefault undefined
Description The mode determines which platform styles to use. Attribute modeType "ios" ๏ฝ "md"Default undefined
Description The position of the toast on the screen. Attribute positionType "bottom" ๏ฝ "middle" ๏ฝ "top"Default 'bottom'
Description If true, the toast will be translucent."ios" and the device supportsbackdrop-filter Attribute translucentType booleanDefault false
Name Description ionToastDidDismissEmitted after the toast has dismissed. ionToastDidPresentEmitted after the toast has presented. ionToastWillDismissEmitted before the toast has dismissed. ionToastWillPresentEmitted before the toast has presented. 
Description Dismiss the toast overlay after it has been presented. Signature dismiss(data?: any, role?: string ๏ฝ undefined) => Promise<boolean>
Description Returns a promise that resolves when the toast did dismiss. Signature onDidDismiss<T = any>() => Promise<OverlayEventDetail<T>>
Description Returns a promise that resolves when the toast will dismiss. Signature onWillDismiss<T = any>() => Promise<OverlayEventDetail<T>>
Description Present the toast overlay after it has been created. Signature present() => Promise<void>
Name Description buttonAny button element that is displayed inside of the toast. containerThe element that wraps all child elements. headerThe header text of the toast. iconThe icon that appears next to the toast content. messageThe body text of the toast. 
Name Description --backgroundBackground of the toast --border-colorBorder color of the toast --border-radiusBorder radius of the toast --border-styleBorder style of the toast --border-widthBorder width of the toast --box-shadowBox shadow of the toast --button-colorColor of the button text --colorColor of the toast text --endPosition from the right if direction is left-to-right, and from the left if direction is right-to-left --heightHeight of the toast --max-heightMaximum height of the toast --max-widthMaximum width of the toast --min-heightMinimum height of the toast --min-widthMinimum width of the toast --startPosition from the left if direction is left-to-right, and from the right if direction is right-to-left --white-spaceWhite space of the toast message --widthWidth of the toast