react-native-modal /react-native-modal

An enhanced, animated, customizable Modal for React Native.

★ 5,650⑂ 658👁 38⑃ 276● 523▤ 61
TypeScriptMITCreated 2016-09-23
Download: v13.0.1v13.0.1 ↓13.0.12022-03-01
+0
Daily
5,650
stars
658
forks
38
watchers
276
prs
523
issues
61
releases

README

Announcements

- 📣 We're looking for maintainers and contributors! See 598
- 🙏 If you have a question, please start a new discussion instead of opening a new issue.

 react-native-modal




 If you're new to the React Native world, please notice that React Native itself offers a  component that works out-of-the-box.

An enhanced, animated, customizable React Native modal.

The goal of react-native-modal is expanding the original React Native  component by adding animations, style customization options, and new features, while still providing a simple API.





 Features

- Smooth enter/exit animations
- Plain simple and flexible APIs
- Customizable backdrop opacity, color and timing
- Listeners for the modal animations ending
- Resize itself correctly on device rotation
- Swipeable
- Scrollable

 Setup

This library is available on npm, install it with: npm i react-native-modal or yarn add react-native-modal.

 Usage

Since react-native-modal is an extension of the original React Native modal, it works in a similar fashion.

1.  Import react-native-modal:

javascript
import Modal from 'react-native-modal';


2.  Create a  component and nest its content inside of it:

javascript
function WrapperComponent() {
  return (
    
      
        
          I am the modal content!
        
      
    
  );
}


3.  Then, show the modal by setting the isVisible prop to true:

javascript
function WrapperComponent() {
  return (
    
      
        
          I am the modal content!
        
      
    
  );
}


The isVisible prop is the only prop you'll really need to make the modal work: you should control this prop value by saving it in your wrapper component state and setting it to true or false when needed.

 A complete example

The following example consists in a component (ModalTester) with a button and a modal.
The modal is controlled by the isModalVisible state variable and it is initially hidden, since its value is false.  
Pressing the button sets isModalVisible to true, making the modal visible.  
Inside the modal there is another button that, when pressed, sets isModalVisible to false, hiding the modal.

javascript
import React, {useState} from 'react';
import {Button, Text, View} from 'react-native';
import Modal from 'react-native-modal';

function ModalTester() {
  const [isModalVisible, setModalVisible] = useState(false);

  const toggleModal = () = {
    setModalVisible(!isModalVisible);
  };

  return (
    
      

      
        
          Hello!

          
        
      
    
  );
}

export default ModalTester;


For a more complex example take a look at the /example directory.

 Available props

| Name                             | Type                 | Default                          | Description                                                                                                                                |
| -------------------------------- | -------------------- | -------------------------------- | --------------

Top issues

Discussions

Latest release

v13.0.1 v13.0.1 2022-03-01
13.0.1 (2022-03-01)


 Bug Fixes

 make getDerivedStateFromProps's nextProps param Readonly (647) (c737e7f), closes 381

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON