Toast is used to show alerts on top of an overlay.
Toast will close itself when the close button is clicked, or after a timeout — the default is 5 seconds. The toast component is used to give feeback to users after an action has taken place.
Toasts can be configured to appear at either the top or the bottom of an application window, and it is possible to have more than one toast onscreen at a time.
Display a custom component instead of the default Toast UI.
Toasts can be closed imperatively, individually (via the close instance method) or all together (via the closeAll instance method).
You can use status to change the color of your toasts.
Toast uses the same variants as the Alert component.
In some cases you might need to prevent duplicate of specific toasts. To achieve you need to pass an id and use the toast.isActive method to determine when to call toast.show(...).
Below props can be passed while calling toast.show.
|title||ReactNode||The title to be rendered in the Toast||-|
|description||ReactNode||The description of the toast||-|
|duration||number||The delay before the toast hides (in milliseconds). If set to `null`, toast will never dismiss.||5000|
|id||any||The `id` of the toast. Mostly used when you need to prevent duplicate. By default, we generate a unique `id` for each toast||-|
|isClosable||boolean||If `true`, toast will show a close button||-|
|onCloseComplete||() => void||Callback function to run side effects after the toast has closed.||-|
|placement||"bottom" | "top" | "top-right" | "top-left" | "bottom-left" | "bottom-right"||The placement of the toast. Defaults to bottom||bottom|
|render||(props: any) => ReactNode||Render a component toast component. Any component passed will receive 2 props: `id` and `onClose`.||-|
|status||"info" | "warning" | "error" | "success"||The status of the toast. Adding status will render an [Alert](alert.md) component inside the `Toast`||-|
|variant||"solid" | "subtle" | "left-accent" | "top-accent" | "outline" | "outline-light"||The variants of the [Alert](alert.md) component.||-|
|accessibilityAnnouncement||string||The text to be announced by a screen reader when the Toast opens.||-|
|accessibilityLiveRegion||"none" | "polite" | "assertive"||Determines the [accessibility announcement tone](https://reactnative.dev/docs/accessibility#accessibilityliveregion-android).||-|
Toast implements Box
- On Android and Web, Toast renders under a View with accessibilityLiveRegion which announces the content rendered inside it to screen reader devices.
- On iOS, accessibilityLiveRegion is not supported yet, so we use the accessibilityAnnouncement to announce the content.