Snackbar
Single-action notifications sharing the toast queue.
npx @swipeui/cli add snackbarWhen to use it
- A reversible result with one named application action, such as Undo or Retry.
When not to use it
- Decisions, long instructions or multiple business actions: use Dialog.
Installation
Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.
npx @swipeui/cli add snackbar- Adds
components/swipeui/ui/snackbar.tsxand 12 shared helpers. - Installs react-native-gesture-handler, react-native-reanimated, react-native-safe-area-context, react-native-worklets, react-native-svg, uniwind, clsx, tailwind-merge, expo-haptics, class-variance-authority. In Expo apps it uses
npx expo installso versions match your SDK.
Usage
useSnackbar().show({ title: "Archived", action: { label: "Undo", onPress: undo } });Feedback lineup settings
| Prop | Does / default |
|---|---|
title / preset | Message content; explicit title and description override a preset. |
action | Required named application action, beside a short message. Invokes the callback once and dismisses. |
duration | 0 with an action: persistent unless explicitly timed. |
icon | null; pass a custom node or undefined to show the tone symbol. |
showDismiss | false; opt into a separate 44pt close control. Undo, swipe and the accessibility dismiss action remain available. |
description | Optional detail. Detailed messages place the action below the text. |
Both <Snackbar /> and useSnackbar().show() use these defaults and share one ToastProvider/ToastHost. The content-sized surface wraps long text without a fixed height. Native Dynamic Type, VoiceOver and RTL review remain in 7.9.
The shared archive example uses a bounded conversation card, a rolling Inbox/Archived tag, Undo and an explicit three-second lifetime with exitDirection="up". Direct Snackbar calls still default to persistent action availability; provide duration to opt into expiry.
Archive is the single shared demo board; its Undo action, upward expiry and long-press stack gestures use the same notification queue as Toast. Previous Top/Undo examples are consolidated.
Behavior and gestures
- Persistent until acted on or dismissed unless duration is explicitly set.
- Same safe-area placement, queue, swipe and accessibility pause behaviour as Toast.
Accessibility
- The message is announced when it appears.
- Native screen-reader mode keeps toasts persistent. On the web, focused controls pause expiry; browsers cannot detect screen-reader presence.
- Action and dismiss are named buttons, so swiping is never required.
- Toasts never take focus or block the screen.
Motion
- Uses the
overlayandpressmotion roles, so it follows your app's feel. Passmotionto tune this one instance. - Toasts fade in and out on the overlay role; swipes follow the finger.
- Reduce Motion uses a short fade.
Performance
- One host at the app root renders the queue; it doesn't depend on your router.
Notes for AI
- Use useSnackbar inside ToastProvider. One ToastHost displays both toasts and snackbars.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.