Toast
Stacked notifications that rise in from the bottom, slide out to the right and close the gap with a spring. Swipe right to dismiss, or let them hide on their own. Call them from anywhere with useToast().
Preview
Preview coming soon
Try it live: run the CLI command below in an Expo app, or open the Code tab.
Installation
npx @codewithrabby/ui@latest add toastUsage
import { ToastProvider, useToast } from "@/components/uir/toast";
// 1. wrap your app once (e.g. in app/_layout.tsx)
<ToastProvider>
<Stack />
</ToastProvider>
// 2. call it from any screen
const toast = useToast();
toast.success("Success!", { message: "All files were uploaded." });
toast.error("Error", { message: "Wrong code.", action: { label: "Try again", onPress: retry } });
toast.show({ kind: "warning", title: "Warning", message: "Storage almost full.", duration: 0 });Props
| Prop | Type | Default |
|---|---|---|
childrenYour app. useToast() works anywhere inside. | ReactNode | — |
durationDefault ms before a toast hides. 0 keeps it until dismissed. | number | 4000 |
maxMost toasts on screen at once; older ones are dropped. | number | 3 |
offsetDistance of the stack from the bottom. | number | safe-area bottom + 16 |
themesOverride { bg, border, text, subText } per kind. | Partial<Record<ToastKind, ToastTheme>> | — |
useToast()show(options), info / success / warning / error(title, options), dismiss(id), dismissAll(). Each returns the toast id. | ToastApi | — |
ToastOptions{ kind?, title, message?, action?: { label, onPress? }, duration? } | object | — |