Skip to content

Repository files navigation

react-native-toast-alert

An awesome package for cool toast alerts in react-native πŸš€

Toast.success("Welcome. you will definitely love this toast package.πŸ˜‰")

Installation

npm install react-native-toast-alert

Usage

πŸ‘‰πŸ½ Step 1

Import ToastManager and Toast.

// ...importToastManager{Toast}from'react-native-toast-alert'

πŸ‘‰πŸ½ Step 2

Add ToastManager component to the top of your app component structure.

constApp=()=>{return(<View><ToastManager/><App>
// Other parts of your application content can go here
</App></View>)})

πŸ‘‰πŸ½ Step 3 (Final Step)

Call any of the Toast methods directly

constApp=()=>{// ...constshowSuccessToast=()=>{Toast.success("Yaay!!! You made it here...πŸš€πŸš€πŸš€")}constshowErrorToast=()=>{Toast.error("Error, looks like something went wrong.πŸ™")}constshowInfoToast=()=>{Toast.info("Hi, you're still online.")}constshowWarningToast=()=>{Toast.warning("Your wallet balance is running low.")}return(<View><ToastManager/><TouchableonPress={()=>showSuccessToast()}>
Show
</Touchable></View>)})// ...

Note:

Each of the methods on the toast take 2 parameters: The toast message and an optional list of configuration options.

Options for Configuraton

OptionDescriptionTypeDefault Value
durationHow long the toast will be visible for (milliseconds)number2000
withIconIf there should be an icon in the alertbooleantrue
iconCustom icon image. Works only if withIcon is set to trueImageSourcePropTypeundefined
progressShow progress barbooleanfalse
bounceAdd bounce effect while showing toastbooleanfalse
autoDismissDismiss toast automaticallybooleantrue
centerTextAlign the text in the toast centrallybooleanfalse
dismissModeHow to dismiss the toast manually. (This is useful if you set autoDismiss to false)'tap' or 'swipe'tap

Happy Coding πŸ₯‚

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Releases

Packages

Used by

Contributors

Languages