React Native · Components
Toaster
Places notifications shown with toast on screen.
10 exports
Import
Toaster
componentPlaces notifications shown with toast on screen. Use it once at the app root, inside UIProvider. Same props as the web Toaster.
- Always on top: Drawn above open Dialogs and Sheets; does not block the screen behind.
- Stack: Newest in front; expands into a list on tap.
- Timers pause smartly: Timers do not run while the stack is expanded or the app is in the background.
- Swipe to dismiss: On phones towards the edge (bottom ones down, top ones up), sideways on tablets.
- Accessibility: New notifications are read to screen readers.
- Respects notch and bottom bar insets and the open keyboard; looks the same on iOS and Android.
Examples
toast
constantShows a short notification (toast) and returns its id. Same API as toast on web. Can be called from anywhere; the app needs a Toaster for it to show.
Examples
ToastVariant
typeNotification type; sets its color, icon and screen reader behavior.
ToastAction
interfaceAction button in the notification.
| Name | Type | Description |
|---|---|---|
label | ReactNode | Button text. |
onClick | () => void | Called on press; then the notification closes (onClick on web). |
ToastOptions
interfaceOptions that can be given when showing a notification with toast.
| Name | Type | Default | Description |
|---|---|---|---|
id? | string | Notification id. Calling again with the same id does not open a new notification; it updates the existing one (e.g. "Loading" → "Saved"). | |
description? | ReactNode | Description under the title. | |
variant? | ToastVariant | "default" | Notification type. |
icon? | IconProp | Icon at the start of the title. Defaults to the type's own icon; false shows no icon. | |
duration? | number | Auto-dismiss duration (ms). Infinity keeps it until the user closes it. Defaults to the Toaster setting; the "loading" type never auto-dismisses. | |
action? | ToastAction | Action button in the notification (e.g. "Undo"). | |
onDismiss? | () => void | Called when the notification closes in any way. |
ToastData
interfaceRecord of a notification shown on screen.
| Name | Type | Description |
|---|---|---|
id | string | Notification id. |
title | ReactNode | Notification title. |
variant | ToastVariant | Notification type. |
closing | boolean | Is the exit animation playing? |
version | number | Increments on every update; the timer restarts. |
description? | ReactNode | Description under the title. |
icon? | IconProp | Icon at the start of the title. Defaults to the type's own icon; false shows no icon. |
duration? | number | Auto-dismiss duration (ms). Infinity keeps it until the user closes it. Defaults to the Toaster setting; the "loading" type never auto-dismisses. |
action? | ToastAction | Action button in the notification (e.g. "Undo"). |
onDismiss? | () => void | Called when the notification closes in any way. |
ToastPromiseMessages
interfacetoast.promise messages; success and error messages can be produced from the result.
| Name | Type | Description |
|---|---|---|
loading | ReactNode | Title shown while the promise is pending. |
success | ReactNode | ((value: T) => ReactNode) | Title shown when the promise succeeds; can also be produced from the result value. |
error | ReactNode | ((error: unknown) => ReactNode) | Title shown when the promise fails; can also be produced from the error. |
ToastFunction
interfaceType of the toast function.
| Name | Type | Description |
|---|---|---|
success | VariantShortcut | Shows a success notification. |
error | VariantShortcut | Shows an error notification; read to screen readers immediately. |
warning | VariantShortcut | Shows a warning notification. |
loading | VariantShortcut | Shows a "loading" notification that stays until the user closes it or it is updated. |
dismiss | (id?: string): void | Closes the notification. Closes all of them if no id is given. |
ToastPosition
typePosition of notifications on screen (same as web).
ToasterProps
interfaceProps of the Toaster component.
| Name | Type | Default | Description |
|---|---|---|---|
position? | ToastPosition | "bottom-center" | Position on wide screens (tablet). On phones notifications are always full width and only the top/bottom choice is kept. |
stack? | boolean | true | Stacks notifications: the newest in front, earlier ones peeking slightly behind. Tapping the stack expands them into a list (timers pause); tapping outside or tapping again collapses them. With false they are always listed one below another. |
duration? | number | 5000 | Default auto-dismiss duration (ms). |
visibleToasts? | number | 3 | Maximum number of notifications visible at once. The rest are queued and shown when space frees up; their timers do not run while queued. |
label? | string | the `notifications` text (`"Bildirimler"`) | Region name for screen readers. |