Skip to main content

add

Function for creating a toast notification based on the provided configuration.

info

When a toast is created, it inherits options from the Toaster, but the toast's own options will override the Toaster's properties.

info

id option is available only for the add function.

TitleDescriptionTypeDefault
idUnique identifier for the toast.stringuuid
messageThe main content or message displayed in the toast.stringHave a good day 🙂
titleThe title of the toast, displayed above the title. First word will be capitalized.stringbase
positionDefines where the toast will appear on the screen.ToastPositionbottom-right
typeSpecifies the type of toast (e.g., success, error).ToastTypebase
orderDetermines the display order of the toast.DisplayOrdernormal
inAnimationAnimation applied when the toast appears.ToastInAnimationslideVerticallyIn
outAnimationAnimation applied when the toast disappears.ToastOutAnimationslideHorizontalWithFadeInBody
inBodyAnimationAnimation for the toast body when it appears.ToastInBodyAnimationslideVerticallyOut
hideOnClickIf true, the toast hides when clicked.booleantrue
autoHideDuration in ms before the toast automatically hides.number3000
delayBeforeShowDelay before the toast is shown.number0
showProgressIf true, displays a progress bar indicating remaining time.booleantrue
showIconIf true, shows an icon in the toast.booleantrue
showHideButtonIf true, shows a button to manually hide the toast.booleantrue
animateBodyIf true, the body of the toast will have animation.booleantrue
rtlIf true, displays the toast in right-to-left layout.booleanfalse
pauseOnHoverIf true, pauses auto-hide timer when the toast is hovered.booleantrue
pauseOnFocusLossIf true, pauses auto-hide timer when window loses focus.booleantrue
dragOnMobileIf true, the toast can be dragged on mobile devices.booleantrue
removeOnDraggingPercentPercentage of drag distance on mobile before removal.number70
themeSpecifies the theme className of the toast.ToastTheme""
iconClassNameCustom class name for the icon.string""
hideButtonClassNameCustom class name for the hide button.string""
contentClassNameCustom class name for the toast content.string""
containerClassNameCustom class name for the toast container.string""
bodyClassNameCustom class name for the toast body.string""
progressBarClassNameCustom class name for the progress bar.string""
classNameCustom class name for the entire toast.string""
roleARIA role attribute for accessibility.stringalert
iconStyleCustom CSS styles for the icon.CSS.Properties<string | number>{}
hideButtonStyleCustom CSS styles for the hide button.CSS.Properties<string | number>{}
contentStyleCustom CSS styles for the toast content.CSS.Properties<string | number>{}
containerStyleCustom CSS styles for the toast container.CSS.Properties<string | number>{}
bodyStyleCustom CSS styles for the toast body.CSS.Properties<string | number>{}
progressBarStyleCustom CSS styles for the progress bar.CSS.Properties<string | number>{}
styleCustom CSS styles for the entire toast.CSS.Properties<string | number>{}
onShowingCallback function triggered when the toast starts to show.ToastCallbackundefined
onHidingCallback function triggered when the toast starts to hide.ToastCallbackundefined
onShowCallback function triggered when the toast is fully shown.ToastCallbackundefined
onHideCallback function triggered when the toast is fully hidden.ToastCallbackundefined
onClickCallback function triggered when the toast is clicked.ToastCallbackundefined

Example

const config: Partial<ReactToastConfig> = {
position: "bottom-right",
type: "base",
title: "base",
order: "normal",
inAnimation: slideVerticallyIn,
outAnimation: slideVerticallyOut,
inBodyAnimation: slideHorizontalWithFadeInBody,
autoHide: 7000,
theme: "toastup__toast-theme--colorful",
hideOnClick: true,
showProgress: true,
showIcon: true,
showHideButton: true,
animateBody: true,
rtl: false,
pauseOnHover: true,
dragOnMobile: true,
};
add(config);