UIR

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 toast

Usage

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

PropTypeDefault
children

Your app. useToast() works anywhere inside.

ReactNode—
duration

Default ms before a toast hides. 0 keeps it until dismissed.

number4000
max

Most toasts on screen at once; older ones are dropped.

number3
offset

Distance of the stack from the bottom.

numbersafe-area bottom + 16
themes

Override { 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—