Flick Toast
A React Native stack of toasts you flick away, with a countdown line that waits while you hold, older toasts scaled back, and screen reader dismiss.
A stack of toasts you flick away. The newest slides in at the front with the older ones scaled back behind it. A thin line counts down the front toast's time and waits while you hold it, and a sideways or toward-the-edge flick sends it off. The host owns the list: remove a toast in onDismiss. Each toast is a live region with a dismiss action for screen readers. Built for React Native and Expo with react-native only; this page previews it in the browser through react-native-web.
Installation
CLI
npx @modus-ui/cli add flick-toastManual
- Copy the code from the component tab.
- Create a file at
components/ui/flick-toast.tsx. - Paste the code.
It needs no packages beyond react-native, which your Expo or React Native app already has.
Usage
The parent must fill the area the toasts should float over. Only the newest three are drawn; the rest wait their turn.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
toasts | FlickToastItem[] | - | The toasts to show, oldest first. Each has an id, a title, and optional description and tone. |
onDismiss | (id: string) => void | - | Called once a toast has left, whether it timed out, was flicked away or dismissed by a screen reader. |
duration | number | 4000 | Milliseconds the front toast stays before it leaves. 0 keeps toasts until they are dismissed. |
position | "top" | "bottom" | "top" | Which edge the stack sits against. |
colors | Partial<FlickToastColors> | - | Overrides surface, text, mutedText, border, accent, success and error. |
style | StyleProp<ViewStyle> | - | Style for the overlay that holds the toasts. |
Comments