An open API service indexing awesome lists of open source software.

https://github.com/gstj/react-native-magic-toast

🦄 A beautiful imperative toast you can call from anywhere!
https://github.com/gstj/react-native-magic-toast

modal react-native toast

Last synced: over 1 year ago
JSON representation

🦄 A beautiful imperative toast you can call from anywhere!

Awesome Lists containing this project

README

          

![React Native Magic Toast Cover](https://user-images.githubusercontent.com/50031755/182908210-860f7e09-a644-4a74-8000-46f7f5bbf01e.png)

# React Native Magic Toast 🦄

A beautiful Toast library that can be called imperatively from anywhere!

| IOS | Android |
| ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| | |

## Installation

```sh
yarn add react-native-magic-toast react-native-magic-modal react-native-safe-area-context
```

This toast uses [react-native-magic-modal](https://github.com/GSTJ/react-native-magic-modal) as a base for displaying it anywhere. [react-native-safe-area-context](https://github.com/th3rdwave/react-native-safe-area-context) is here to prevent the modal message from being underneath safe areas.

## Usage

Insert a SafeAreaProvider encapsulating your app and a MagicModalPortal right beneath it

```js
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { MagicModalPortal } from 'react-native-magic-modal';

export default function App() {
return (


//

);
}
```

Then, you are free to use the magicToast as shown from anywhere you want.

```js
import { magicToast } from 'react-native-magic-toast';

// ...

magicToast.alert('Oops! Something went wrong 😬');
magicToast.success('Hurray! Saved successfully');

// You can also use the show method to render a custom toast
magicToast.show(() => (
/**
* Toast.Container is obligatory as it handles the duration, but you are free
* to customize the View as you wish. You can change the default background color,
* padding, everything! The rest of the components are optional and just help you
* to build a toast faster.
*/


My custom toast

));
```

## Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

## License

[MIT](LICENSE.md)

Made with 💖 by [Gabriel Taveira](https://github.com/GSTJ)