React Native Create Material Design SnackBar in Android iOS Example

SnackBar is a custom bottom to top fixed sized swipeable layout containing 1 line text message with UNDO button, It would automatically hide after a given time. SnackBar is used to show light weight feedback on any operation in android mobile phone applications, But now using React Native mobile application programming language we could develop SnackBar for both Android and iOS devices. So in this tutorial we would going to create a material design custom SnackBar with animation for both Android and iOS mobile phone applications.


Special Thanks to my friend Pankaj Sood, Who actually make this SnackBar.

Contents in this project Create Material Design SnackBar in Android iOS Example :

1. Start a fresh React Native project. If you don’t know how then read my this tutorial.

2. Import AppRegistryAnimated, View, Platform, Button, Image, StyleSheet and Text component in your project.

3. Create a New class in your project named as MaterialDesignSnackBar .

We are using the React Native’s own Animated component library in our tutorial to show and hide the SnackBar. You don’t need to do anything in this code , I have already made the best for you Guys , Enjoy .

4. Create constructor in your own project’s class with super method.

5. Create a function in your class named as DisplayMaterialDesignSnackBar .

In this function you have to pass your own message text which would automatically set inside the SnackBar.

6. Crate a Parent View in render’s return block.

7. Add a Button component inside the Parent View and Call the DisplayMaterialDesignSnackBar function on onPress event of button.

8. Create a object of your MaterialDesignSnackBar class like component declaration after Button component and pass the ref = “ReactNativeCodeSnackBar” . This would allow us to show the SnackBar in our application.

9. Create CSS style sheet classes  .

10. Complete source code for index.android.js / index.ios.js file:

Screenshot of Application in iOS mobile phone device :

Material Design SnackBar

Screenshot of Application in Android mobile phone device :