Use the useToast hook to show toasts. Call toast.show() with a message to display a temporary notification.
Actions
Add an action button to the toast for quick user actions like "Undo" or "View".
Without Close Button
Hide the close button when you want a cleaner appearance or when the toast should only be dismissed via the action or timeout.
Duration
Toast duration is automatically calculated based on content length:
- Base duration: 5 seconds
- With action: +2 seconds
- Long text (>50 characters): +0.3s per 10 additional characters
You can override the automatic calculation by providing a custom duration in milliseconds.
Positioning
Use bottomOffset to adjust the vertical position of the toast. This is useful when you have bottom navigation or other fixed elements.
Styling
Variants
Use the variant prop to change the color surge effect on the toast background. This helps communicate the nature of the notification.
Lifecycle Callbacks
Use onWillHide and onDidHide to respond to toast dismissal. This is useful for cleanup or triggering subsequent actions.