useXDSToast@xds/core · Toast

Usage

Hook for showing toast notifications from anywhere in your component tree. Returns a function that accepts toast options and shows the notification. Works automatically with XDSLayerProvider or self-mounts a fallback viewport.

Best practices

GuidancePractices
DoUse for transient success/error feedback that does not require user action.
DoSet uniqueID to deduplicate toasts from rapid user actions.
Don'tUse for critical errors that require acknowledgment — use AlertDialog instead.
Don'tCall useXDSToast in the same component that renders XDSLayerProvider — it must be called from a child component inside the provider.

Returns

FieldTypeDescription
showToast(options: XDSToastOptions) => () => voidShow a toast notification. Returns a dismiss function. Options include body (ReactNode), type ("info" | "error"), isAutoHide, autoHideDuration, endContent, uniqueID, and collisionBehavior.

Import

ts
import {useXDSToast} from '@xds/core/Toast'