Make Swipe Button in React Native for Android and iOS

This is an Example to Make Swipe Button in React Native for Android and iOS. Swipe button is a very interesting and attractive feature for submitting the form of any other thing which needs confirmation. We can use this type of button for the choice section as we do in case if the switch or we can use it where we want the user to be sure about the action.

In some cases, the user says he/she has accidentally clicked on the button which can create the problem in very sensitive case so to stop that I personally like to provide swipeable button so that users have to put some efforts and it can not be done accidentally. If you have used the iPhone then you have seen the same Swipeable button while switching off the device.

For this example, we are using SwipeButton component provided by rn-swipe-button library.

To Make a Swipe Button

You can see here for the more customizable props.

In this example, we will make a swipeable button which has success threshold =70 and has a custom title with custom properties like background color, border color, thumb icon background color, thumb icon border-color. After swiping the button it will trigger onSwipeSuccess where you can add your to-do (We are showing alert only). So let’s get started with the example.

To Make a React Native App

Getting started with React Native will help you to know more about the way you can make a React Native project. We are going to use react-native init to make our React Native App. Assuming that you have node installed, you can use npm to install the react-native-cli command line utility. Open the terminal and go to the workspace and run

npm install -g react-native-cli

Run the following commands to create a new React Native project

react-native init ProjectName

If you want to start a new project with a specific React Native version, you can use the --version argument:

react-native init ProjectName --version X.XX.X
react-native init ProjectName --version react-native@next

This will make a project structure with an index file named App.js in your project directory.

Installation of Dependency

To use SwipeButton we need to install rn-swipe-button dependency.

To install this open the terminal and jump into your project using

Run the following command to install

This command will copy all the dependency into your node_module directory.

Code to make a swipeable button

Now Open App.js in any code editor and replace the code with the following code.


To Run the React Native App

Open the terminal again and jump into your project using.
cd ProjectName
To run the project on an Android Virtual Device or on real debugging device
react-native run-android
or on the iOS Simulator by running
react-native run-ios (macOS only).


Image   Image   Image   Image

This is how you can make swipe button in React Native for Android and iOS. If you have any doubt or you want to share something about the topic you can comment below or contact us here. There will be more posts coming soon. Stay tuned!

Hope you liked it. 🙂

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.