Skip to content

useToast

@astryxdesign/core v0.7.1 · useToast

Returns ​

NameTypeDescription
show(options: ToastOptions) => () => voidShow a toast notification. The returned function dismisses that toast. The hook itself is callable, so toast({ body }) and toast.show({ body }) are the same.
dismiss(id: string) => voidDismiss a toast by id. It hangs off the returned function: toast.dismiss(id).
clear() => voidDismiss every visible toast. Called as toast.clear().

Toast options ​

NameTypeDefaultDescription
bodystring—The message. Required.
type'info' | 'success' | 'warning' | 'error''info'Visual type of the toast.
isAutoHidebooleantrueWhether the toast dismisses itself. error toasts stay until they are dismissed.
autoHideDurationnumber5000Auto-dismiss duration in milliseconds.
uniqueIDstring—Identity shared by toasts that should collapse into one.
collisionBehavior'ignore' | 'overwrite''overwrite'How a uniqueID clash is resolved.
endContentComponent—Trailing action rendered after the message, such as an undo button.
onDismiss(reason: 'auto' | 'manual') => void—Runs when the toast card dismisses itself: the timer, the close button, or a swipe.
onHide(reason: 'auto' | 'manual') => void—Runs when the toast is removed, however it was dismissed.