Super Toast

Callbacks & haptics

React to presses, dismissals, and timeouts, and add haptic feedback.

Callbacks

toast('Draft saved', {
  onPress: () => openDrafts(),
  onDismiss: (id) => console.log('dismissed', id),
  onAutoClose: (id) => console.log('timed out', id),
});
CallbackCalled when
onPressThe toast body is pressed.
onDismissThe toast is swiped away, closed, cancelled, or dismissed with toast.dismiss.
onAutoCloseThe toast's duration elapses.
action.onClickThe action button is pressed. The toast is then dismissed.
cancel.onClickThe cancel button is pressed, before onDismiss.

Each dismissal callback runs at most once per toast.

Haptics

Play a light haptic when a toast appears or updates.

<ToastHost haptic />;

toast.success('Paid', { haptic: true });

iOS uses UIImpactFeedbackGenerator; Android uses the window's haptic feedback.

On this page