An opinionated toast component for React Native. A port of @emilkowalski's sonner.
- API fully matches Sonner's
- Multiple variants, including
success
,error
,warning
,custom
,promise
- Promise variant with built-in loading state
- Custom JSX with the custom variant
- Top or bottom positions
- Title and description
- Action button with a callback
- Custom icons
- Optionally dismissable with swipe, configurable left or up
- Dismissable with toast.dismiss(), one or all toasts
- Highly performant using Reanimated 3, 60 FPS
- Dark mode built-in
- Works with Expo
- NativeWind supported
- Customizable via styles props
- Works outside of React components
![Screenshot 2024-09-06 at 16 33 10](https://private-user-images.githubusercontent.com/5333875/365241717-fb986f0f-6f5a-4716-9633-6dfe492a9e9c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1MTQ1MjgsIm5iZiI6MTczOTUxNDIyOCwicGF0aCI6Ii81MzMzODc1LzM2NTI0MTcxNy1mYjk4NmYwZi02ZjVhLTQ3MTYtOTYzMy02ZGZlNDkyYTllOWMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTRUMDYyMzQ4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZjllMjdkMTA3MDAxMDI4MjRiMDg5ZWYwY2VlNWE0NWQ0ZWZiOWFjOTI0Njg0MTgwMjhhNTc3YzI3NTU0OTE1OCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.CIdkFevFeaZoqkgDCsbS2-nYctxUbfs-svNcjLOYYF0)
![Screenshot 2024-09-06 at 16 32 27](https://private-user-images.githubusercontent.com/5333875/365241821-8fa438c4-3c65-4f8f-ad15-52cc24e1faf5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1MTQ1MjgsIm5iZiI6MTczOTUxNDIyOCwicGF0aCI6Ii81MzMzODc1LzM2NTI0MTgyMS04ZmE0MzhjNC0zYzY1LTRmOGYtYWQxNS01MmNjMjRlMWZhZjUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTRUMDYyMzQ4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NGFkMGM1OWUxODdjNzhmYWQyYmMxODNjODFmZTRkMzcxOTA0ODI1OWI4MTE0OWI3NWY2NGQ1NjlkMzhhMmQzYiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.egnhW156I3oSg-U9LDLjOv9hLjmYTarXbnQ6Gd8oL8k)
![Screenshot 2024-09-06 at 16 32 33](https://private-user-images.githubusercontent.com/5333875/365241790-fe43bc29-5d25-4e32-a88c-bba6e58a6eda.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1MTQ1MjgsIm5iZiI6MTczOTUxNDIyOCwicGF0aCI6Ii81MzMzODc1LzM2NTI0MTc5MC1mZTQzYmMyOS01ZDI1LTRlMzItYTg4Yy1iYmE2ZTU4YTZlZGEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LU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tei1TaWduZWRIZWFkZXJzPWhvc3QifQ.HBbeDxtaJleN0OKDprf18ZGVP9I5ET35i3Aa5AvGOF0)
![Screenshot 2024-09-06 at 16 33 04](https://private-user-images.githubusercontent.com/5333875/365241714-bbc20957-160f-43c1-b317-b64512ec7cef.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1MTQ1MjgsIm5iZiI6MTczOTUxNDIyOCwicGF0aCI6Ii81MzMzODc1LzM2NTI0MTcxNC1iYmMyMDk1Ny0xNjBmLTQzYzEtYjMxNy1iNjQ1MTJlYzdjZWYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTRUMDYyMzQ4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Mjg1MDg4NzQyNTJjMDRiMzAyNDM4NDlhYTY1MzAxNWU5NjY3YjllYTI5MTU1NzZlM2RlNzk0MDkyZWQ1YjE0NyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.mEzDuLNk8Qi3CP8lrZ_cV6aLcs7Viam11_DsZGpQMjs)
https://snack.expo.dev/@gunnartorfis/sonner-native
npx expo install sonner-native
To use this package, you also need to install its peer dependencies. Check out their documentation for more information:
- React Native Reanimated
- React Native Gesture Handler
- React Native Safe Area Context
- React Native SVG
import { Toaster } from 'sonner-native';
function App() {
return (
<View>
<NavigationContainer>...</NavigationContainer>
<Toaster />
</View>
);
}
import { toast } from 'sonner-native';
function SomeComponent() {
return (
<Button
title="Show Toast"
onPress={() => toast('Hello, World!')}
/>
);
}
Even though Sonner Native works on the web, it is not recommended to use it there. Instead, use the original Sonner.
The following setup is recommended. Add a sonner.ts
and sonner.web.ts
file to your project and import from there instead of from this library directly. That way, sonner will be used on the web and sonner-native on native.
// sonner.ts
export * from 'sonner-native';
// sonner.web.ts
export * from 'sonner';
For more advanced usage, check out the documentation
demo.mov
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
Made with create-react-native-library