Skip to main content

Configuration

All options can be passed per-call as the last argument to showToastX()/show(), or set as global defaults once via provideNgxToast(withToastConfig({...})) / NgxToastModule.forRoot({...}).

OptionTypeDefaultDescription
titlestring''Title for the toast message
positionenumTopRightToast stack position
durationnumber3000Time to live in milliseconds (when autoClose)
closeButtonbooleanfalseShow a close button
showIconbooleantrueShow the type icon (success/info/warning/error)
tapDismissbooleanfalseClose when the toast itself is clicked
autoClosebooleantrueAutomatically close after duration
animationDurationnumber200Open/close CSS transition duration (ms)

Generic show()​

Alongside the four typed methods (showToastSuccess, showToastInfo, showToastWarning, showToastError), a generic method is also available:

import { NgxToastType } from 'ngx-toastf'

toastService.show(NgxToastType.Info, 'Hello world!')

Stacking​

Calling any showToastX()/show() again while a toast is visible stacks a new toast rather than replacing the existing one - multiple toasts (even in the same position) coexist until each closes on its own.