Mobile › Overlays
Toast
A short message after an action, with an optional Undo. Wrap the app in ToastProvider and call useToast().
Installation
npx expo install plankui-mobile react-native-safe-area-context expo-hapticsUsage
import { ToastProvider, useToast, Button } from "plankui-mobile";
// Once, near the root:
<ToastProvider bottomOffset={80}>{/* app */}</ToastProvider>
// Anywhere inside:
const toast = useToast();
toast("Saved");
toast({ message: "Message deleted", action: { label: "Undo", onPress: restore } });
toast({ message: "Couldn't upload", tone: "error" });iOS and Android
iOS: A pill that drops from the top; screen readers announce it.
Android: A Material snackbar at the bottom, above the tab bar.
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| message | string | What happened. | |
| action | { label: string; onPress: () => void } | – | One action, such as Undo. |
| tone | "default" | "success" | "error" | "default" | Adds a coloured dot and a matching haptic. |
| duration | number | 4000 | Milliseconds; 6000 when there is an action. |
ToastProvider
| Prop | Type | Default | Description |
|---|---|---|---|
| bottomOffset | number | 0 | Space kept clear at the bottom on Android, such as the tab bar height. |