react-native-modal /react-native-modal
An enhanced, animated, customizable Modal for React Native.
★ 5,650⑂ 658👁 38⑃ 276● 523▤ 61
+0
日增长
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
#236ScrollView inside swipeable modal is not working93 comments · 2019-01-09#147backdrop doesn't cover screen on Samsung Galaxy S891 comments · 2018-04-20#737[Android]: OnPress not working when modal is open after updating react native version 23 comments · 2023-03-29#344Android keyboard avoid issue20 comments · 2019-08-16#516The keyboard does not pop up when the Android Textinput autoFocus is true19 comments · 2021-01-20#734backdrop flickering on both IOS and Android14 comments · 2023-03-16#453[Android] Button that created TouchableOpacity not triggering first click13 comments · 2020-06-29#793RN 0.78 and 14.0.0-rc.0 error13 comments · 2025-03-10
Discussions
#839The errorr0 comments · 2026-01-14#824modal New version0 comments · 2025-08-12#79214.0.0-rc.02 comments · 2025-03-08#79114.0.0-rc.00 comments · 2025-03-08#782react-native-modal for Accessibility0 comments · 2025-01-26#780Dynamic modal heights0 comments · 2025-01-23#779is there a way to completely disable animation for showing/hiding the modal?0 comments · 2025-01-21#760on first tap inside modal content only keyboard is collapsing, and in next tap the onPress method was executing.0 comments · 2023-11-29
Latest release
v13.0.1 v13.0.1 2022-03-0113.0.1 (2022-03-01) Bug Fixes make getDerivedStateFromProps's nextProps param Readonly (647) (c737e7f), closes 381