Skip to content

Toast

Toast displays brief, non-intrusive messages that automatically disappear. Use for confirmations, status updates, and non-critical notifications.

Reading saved successfully
Hexagram added to favorites
Connection unstable
Failed to save reading

Neutral toast for general messages.

Your changes have been saved
showToast({ message: 'Your changes have been saved' });

Confirms successful actions.

Reading saved successfully
showToast({
message: 'Reading saved successfully',
variant: 'success'
});

Alerts to potential issues.

Offline mode - changes will sync later
showToast({
message: 'Offline mode - changes will sync later',
variant: 'warning'
});

Indicates failures or errors.

Failed to load hexagram data
showToast({
message: 'Failed to load hexagram data',
variant: 'error'
});

Provides informational updates.

New features available
showToast({
message: 'New features available',
variant: 'info'
});

top
Message
bottom
Message
// Top position
showToast({
message: 'New notification',
position: 'top'
});
// Bottom position (default)
showToast({
message: 'Action completed',
position: 'bottom'
});

Control how long the toast is visible.

// Short (2 seconds)
showToast({
message: 'Quick update',
duration: 2000
});
// Default (3 seconds)
showToast({
message: 'Standard message',
duration: 3000
});
// Long (5 seconds)
showToast({
message: 'Important information',
duration: 5000
});
// Persistent (until dismissed)
showToast({
message: 'Action required',
duration: 0
});

Wrap your app with ToastProvider to enable toasts.

import { ToastProvider } from '@synchronicity/react-native';
function App() {
return (
<ToastProvider>
<YourApp />
</ToastProvider>
);
}

PropTypeDescription
childrenReactNodeApp content
MethodTypeDescription
showToast(config: ToastConfig) => voidShow a toast
hideToast() => voidHide current toast
PropTypeDefaultDescription
messagestringRequiredToast message
variant'default' | 'success' | 'warning' | 'error' | 'info''default'Visual variant
durationnumber3000Display time in ms (0 for persistent)
position'top' | 'bottom''bottom'Screen position

import { ToastProvider, useToast, Button, Card } from '@synchronicity/react-native';
import { View } from 'react-native';
function SaveReadingButton({ reading }) {
const { showToast } = useToast();
const handleSave = async () => {
try {
await saveReading(reading);
showToast({
message: 'Reading saved to your journal',
variant: 'success',
duration: 3000
});
} catch (error) {
showToast({
message: 'Failed to save reading. Please try again.',
variant: 'error',
duration: 5000
});
}
};
return (
<Button onPress={handleSave}>
Save Reading
</Button>
);
}
// App setup
function App() {
return (
<ToastProvider>
<SaveReadingButton reading={currentReading} />
</ToastProvider>
);
}