Recognized by Clutch.co as a top-rated Mobile App Development Company.
folio3-mobile
US 408 365 4638
START YOUR PROJECT
  • Solutions
    • Apps Discovery Services
    • Team Augmentation
    • Enterprise
    • AR/VR
    • IoT
    • Wearables
    • Field Sales
    • On Demand Apps
  • Industries
    • Retail
    • Agriculture
    • Healthcare
    • Pharmaceutical & Life Sciences
    • Manufacturing
    • Automotive
    • Logistics
    • Education
  • Technologies
    • Native Mobile Apps
      • iOS
      • Android
    • Cross Platform Apps
      • React Native
      • Flutter
      • Ionic
      • Xamarin
      • NativeScript
      • Sencha
  • Portfolio
  • Blog
  • Contact Us
  • Solutions
    • Apps Discovery Services
    • Team Augmentation
    • Enterprise
    • AR/VR
    • IoT
    • Wearables
    • Field Sales
    • On Demand Apps
  • Industries
    • Retail
    • Agriculture
    • Healthcare
    • Pharmaceutical & Life Sciences
    • Manufacturing
    • Automotive
    • Logistics
    • Education
  • Technologies
    • Native Mobile Apps
      • iOS
      • Android
    • Cross Platform Apps
      • React Native
      • Flutter
      • Ionic
      • Xamarin
      • NativeScript
      • Sencha
  • Portfolio
  • Blog
  • Contact Us

Create your first modal popup in react native

Published by: Muhammad Saqlain | October 27, 2020
SCROLL AND BE AMAZED!
Home > React Native > Create your first modal popup in react native

React native offers a list of reusable components to select from. Using these reusable components saves time and avoids duplication. However, developers can easily create custom components as per need.

The Modal component provides a foundation to present content above an enclosing view. It can be used to show popovers, alerts, dialogs and much more. React Native offers a basic Modal component which can be customized as per need.

Modal needs to be imported from react-native and we can control its visibility by setting visible prop.

The transparent prop can be used to toggle between the entire view and transparent background.

import {Modal} from 'react-native';
 
 class Modal extends Component {
   constructor(props) {
   	this.state = {
		isVisible: false,
};
   }
   setVisibility(visible) {
     this.setState({isVisible: visible});
   }
    render() {
     return (
       <View>
         <Modal transparent visible={this.state.isVisible}>
           <View>
             <View>
               <Text>Demo Modal!</Text>
                <TouchableHighlight
                 onPress={() => { this.setVisibility(!this.state.isVisible); }}>
                 <Text>Hide</Text>
               </TouchableHighlight>
             </View>
           </View>
         </Modal>
          <TouchableHighlight onPress={() => { this.setVisibility(true); }}>
           <Text>Show</Text>
         </TouchableHighlight>
       </View>
     );
   }
 }

Full list of props can be found in the official documentation of react-native.

React native is very popular among developers around the world as a large and growing community. React native community offers a more enhanced, animated, and customizable react-native modal. Built on top of react-native modal with much more options animations and styles.

How to make Transparent Background

Modal offers a transparent prop that determines if your modal fills the entire view or not. Setting transparent prop value to true will render the modal over a transparent background and takes away the focus of screen to modal.

How to animate modal

Developers can easily pass animation type in animationIn and animationOut prop. By default animationIn is set to slideInUp and animationOut is set to slideOutDown. Developers can set the timing of animation in ms.

Disabling gestures

Gestures can be controlled by passing value in swipeDirection prop. By default, there is no gesture set. Possible values for the direction where the modal can be swiped are Up, Down, Left or Right. It also supports multiple values that can be passed in an array like ['left', 'right'].

How to center align

To control the alignment of modal content especially in larger devices like iPad or tabs, modal offers presentationStyle property that controls how the modal appears. Possible values are fullScreen (covers the screen completely), formSheet, overFullScreen (Allows transparency, cover full screen).

By default, the presentationStyle prop is set overFullScreen or fullScreen depending on the transparent prop.

Scrollable Content

React Native Modal supports scrollable content inside the modal box. It supports Horizontal scroll too & it can be enabled by setting scrollHorizontal prop to true which is by default false. By setting scrollOffset, content gets scrollable, and swipe to close gesture gets disabled.

I recommend using the community version as it has more options, animations, and features. Documentation can be found at https://github.com/react-native-community/react-native-modal

Have I missed something? please feel free to post in the comments.


About msaqlain

A hardworking and dedicated individual, determined on the road to success, ever ready to take on challenges and accomplish what I set out to achieve.

Newsletter

Search

Archives

  • December 2023
  • April 2023
  • March 2023
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • October 2021
  • September 2021
  • May 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • July 2019
  • May 2019

Recent Posts

  • Exploring Flutter Navigation: From Basics to Advanced Routes
  • Web UI Test Automation with Pytest-BDD
  • How to fix IOS compass calibration issues
  • Testing Android Applications With Perfect Coverage
  • How to use useRef hook efficiently? – React

Tags

  • android
  • angular-state-management
  • Automation
  • Compass
  • cross-platform
  • css
  • development
  • firebase
  • hooks
  • ios
  • learn-ngrx
  • ngrx-beginner
  • ngrx/store
  • QA
  • react-native
  • reactjs
  • scss
  • stylesheet
  • styling
  • Testing
  • Test Script
  • UI-UX

Newsletter

Newsletter

Post navigation

Previous Leaflet: An Alternative to React Google Maps with Search Functionality
Next How to reduce apk size in React Native
Schedule an Appointment with our Mobile App Development Expert
Footer Menu
  • Company
    • About Us
    • Portfolio
    • Blog
    • Careers
    • Contact Us
  • Solutions
    • Apps Discovery Services
    • Team Augmentation
    • Enterprise App Development
    • AR/VR Application Development
    • IoT Application Development
    • Wearables Apps Development
    • Field Sales
    • On-Demand Apps Development
  • Technologies
    • iOS
    • Android
    • React Native
    • Flutter
    • Ionic
    • Xamarin
    • NativeScript
    • HTML5
    • Sencha
  • Industries
    • Retail
    • Agriculture
    • Healthcare
    • Pharmaceutical
    • Manufacturing
    • Automotive
    • Logistics
    • Education

US Office

Belmont, California – 1301 Shoreway Road, Suite 160, Belmont, CA 94002

Pleasanton, California – 6701 Koll Center Parkway, #250 Pleasanton, CA 94566

Tel: +1 408 365 4638
Support: +1 (408) 512 1812

Mexico Office

Amado Nervo #2200, Edificio Esfera 1 piso 4, Col. Jardines del Sol, CP. 45050, Zapopan, Jalisco, Mexico

Bulgaria Office

49 Bacho Kiro Street, Sofia, 1000, Bulgaria

Canada Office​

895 Don Mills Road, Two Morneau Shepell Centre, Suite 900, Toronto, Ontario, M3C 1W3, Canada

UK Office

Export House, Cawsey Way, Woking Surrey, GU21 6QX

Tel: +44 (0) 14 8361 6611

UAE Office

Dubai, UAE – Dubai Internet City, 1st Floor, Building Number 12, Premises ED 29, Dubai, UAE

Tel: +971-55-6540154
Tel: +971-04-2505173

Pakistan Office

Folio3 Tower, Plot 26, Block B, SMCH Society, Main Shahrah-e-Faisal, Karachi.

First Floor, Blue Mall 8-R, MM Alam Road Gulberg III, Lahore.

Tel: +92-21-3432 3721-4 

© 2025, Folio3 Software Inc., All rights reserved.

  • Privacy policy and terms of use
  • Cookie Policy
Follow us on
Facebook-f Linkedin-in Instagram

Get a free app audit

[contact-form-7 id="3548" title="Float Banner Form"]