toast
toast, a React Native component for iOS, Android and web: Transient notifications that stack above overlays.
Usage
import { Button } from './components/ui/button';
import { Stack } from './components/ui/stack';
import { useToast } from './components/ui/toast';
// The app is wrapped once in <ToastProvider>.
export default function Example() {
const toast = useToast();
return (
<Stack direction="horizontal" gap={2} wrap>
<Button variant="outline" onPress={() => toast.show({ title: 'Saved', tone: 'success' })}>Success</Button>
<Button variant="outline" onPress={() => toast.show({ title: 'Order cancelled', description: 'Your refund is on its way', action: { label: 'Undo', onPress: () => {} } })}>With an action</Button>
<Button variant="outline" onPress={() => toast.show({ title: 'Payment failed', tone: 'danger', duration: null })}>Stays until dismissed</Button>
</Stack>
);
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
position | ToastPosition | ||
align | ToastAlign | Only shows above 512dp wide. Narrower windows are filled, within the margins. | |
duration | number | null | Milliseconds before auto-dismiss. `null` keeps it until dismissed. Default 5000, also with an `action`. | |
animation | ToastAnimation | Default: `{ enter: 'slide', exit: 'fade' }`. Reduced motion skips the movement. | |
animationDuration | number | Milliseconds, for both opening and closing. Default: the theme's `motion.normal` to open and `motion.fast` to close. | |
title | string | ||
description | string | ||
tone | ToastTone | ||
action | { label: string; onPress: () => void } | ||
style | StyleProp<ViewStyle> | ||
testID | string | ||
children | ReactNode |