How to Create Checkbox OnChange Event in React Native?




How to Create Checkbox OnChange Event in React Native?

Hi Guys,

Hello all! In this article, we will talk about how to create checkbox onchange event in react native. we will help you to give example of react native checkbox onchange event example. you can understand a concept of how to use checkbox onchange event in react native. This article will give you simple example of how to implement checkbox onchange event in react native. you will do the following things for checkbox onchange event example in react native.

React native has removed the checkbox component. So in this example, I've used the checkbox-marked icon and the checkbox-blank-outline icon of MaterialCommunityIcons. Then I made a hook that would get the value and set it. I set the value false in that hook. Then import the MaterialCommunityIcons in the Pressable component. I checked the name props in the MaterialCommunityIcons component that if the value in the check is false then the checkbox-marked icon will be set otherwise checkbox-blank-outline.

In the Pressable component, the value is set to true in the setcheck in the onpress props, so I have a condition in the image that if the value in the check is true, the image will change.

Let's start following example:

Step 1: Download Project

In the first step run the following command to create a project.

expo init ExampleApp

Step 2: Install Expo Icons

You install expo vector icons to create checkbox:

npm install @expo/vector-icons

import this:

import { MaterialCommunityIcons } from "@expo/vector-icons";

Step 3: App.js

In this step, You will open the App.js file and put the code.

import React from 'react';

import { StyleSheet, Text, View, Pressable, StatusBar, Image } from 'react-native';

import { MaterialCommunityIcons } from "@expo/vector-icons";

import { Card, Title } from 'react-native-paper';

const App = () => {

const [check, setcheck] = React.useState(false);

return (

<View style={styles.container}>

<View style={ styles.innerContainer}>



<Title style={styles.title}>React Native Checkbox onChange Event</Title>


{!check ?

<Image style={styles.image} source={{ uri: '' }} />


<Image style={styles.image} resizeMode='contain' source={{ uri: '' }} />


<Card.Actions style={styles.checkBox}>

<Pressable onPress={() => setcheck(!check)}>


name={check ? 'checkbox-marked' : 'checkbox-blank-outline'} size={24} color="#000" />


<Text style={styles.checkboxTitle}>Do you want to change the photo?</Text>




<StatusBar />




const styles = StyleSheet.create({

container: {




checkBox: {

justifyContent: "center",

alignItems: "center",

flexDirection: "row",

marginTop: 5,


innerContainer: {




title: {

fontSize: 18,






fontSize: 18,




image: {





export default App;

Run Project

In the last step run your project using the below command.

expo start

You can QR code scan in Expo Go Application on mobile.

Output :

It will help you...

#React Native