Toast

Toasts driven by ToastProvider and useToast: a stacking portal, auto-dismiss, hover pause.

Props

PropTypeDefaultDescription
ToastProvider.durationnumber4000Default auto-dismiss delay, 0 keeps the toast until dismissed
ToastProvider.limitnumber4Maximum number of toasts shown at once
ToastProvider.positionToastPosition'top'Viewport docking direction, six options, defaults to top
ToastProvider.labelstring'Notifications'Accessible name of the viewport region
ToastProvider.onClose(id, reason) => void—Called when any toast closes, with reason manual | timeout | limit
useToast().toast(options) => string—toast(options) pushes a toast and returns its id
useToast().update(id, options) => void—update(id, options) updates an existing toast in place, e.g. loading to success
useToast().dismiss(id?: string) => void—dismiss(id) closes a single toast; call it without an id to close them all
useToast().promise(p, messages) => Promise—promise(p, { loading, success, error }) tracks a promise and switches loading / success / error
optionsToastOptions—toast options: title / description / variant / duration / persistent / dismissible / action
options.descriptionReactNode—When off, the description is hidden and the toast shrinks to a single-line message
options.persistentbooleanfalsePinned toast: never auto-dismisses, hides the close button and is never evicted by limit; close it with dismiss(id)
options.dismissiblebooleantrueWhether the close button shows, defaults to true; always hidden when persistent
childrenReactNode—Provider wraps your application