Toast

Alignment target:@astryxdesign/core v0.7.1 · Toast

Toast Props #

NameTypeDefaultDescription
typeToastType'info'Visual type. Optional: info, success, warning, error.
bodystring-Toast message text.
isAutoHidebooleantrue for every type except errorWhether the toast dismisses itself. Error toasts stay until they are dismissed unless this is set.
autoHideDurationnumber5000Auto-dismiss duration in milliseconds. A pause on hover, focus, or window blur keeps at least one second on the clock.
autoCloseboolean-Older name of isAutoHide. Both work; isAutoHide wins.
durationnumber-Older name of autoHideDuration. Both work; autoHideDuration wins.
uniqueIDstring-Identity shared by toasts that collapse into one.
collisionBehavior'ignore' | 'overwrite''overwrite'What happens when a toast reuses a visible uniqueID.
endContentComponent-Trailing action, such as an undo button. Use the end slot for one-off content.
onDismiss(reason: 'auto' | 'manual') => void-Runs when the toast is dismissed from inside the card: the timer, the close button, or custom content. Options for useToast() only.
onHide(reason: 'auto' | 'manual') => void-Runs when the toast is removed, however it was dismissed, including the dismiss function returned by useToast(). Options for useToast() only.

Toast Events #

NameDescription
dismissEmitted with the reason ('auto' or 'manual') when the card dismisses itself.
closeOlder name of dismiss, emitted at the same time without the reason.

Toast Slots #

NameDescription
defaultCustom toast content. Defaults to body.
endTrailing content, replacing endContent.
contentReplaces the whole card content and receives { body, endContent, type, isAutoHide, autoHideDuration, dismiss }. The empty-state close button is not rendered, so the custom layout owns every control.

ToastViewport Props #

NameTypeDefaultDescription
placementToastPlacement'bottom-end'Position of the toast stack in the viewport. Optional: top-start, top-center, top-end, bottom-start, bottom-center, bottom-end.

useToast #

TypeScript
const toast = useToast()

const dismiss = toast({
  body: 'Hello',
  type: 'info',
  autoHideDuration: 3000,
  onDismiss: reason => console.log('dismissed', reason),
  onHide: reason => console.log('removed', reason),
})
// dismiss manually
dismiss()
// dismiss all
toast.clear()