Javatpoint Logo
Javatpoint Logo

React Native Modal

The React Native Modal is a type of View component which is used to present the content above an enclosing view. There are three different types of options (slide, fade and none) available in a modal that decides how the modal will show inside the react native app.

The Modal shows above the screen covers all the application area. To use the Modal component in our application, we need to import Modal from the react-native library.

Modal Props

Props Description
visible This prop determines whether your modal is visible.
supportedOritentions It allow for rotating the modal in any of the specified orientations (portrait, portrait-upside-down, landscape, landscape-left, landscape-right).
onRequestClose This is a callback prop which is called when the user taps on the hardware back button on Android or the menu button on Apple TV.
onShow This allows passing a function which will show when the modal once visible.
transparent It determines whether the modal will cover the entire view. Setting it to "true" renders the modal over the transparent background.
animationType It controls how the modal animates. There are three types of animated props available:
slide: It slides the modal from the bottom.
fade: It fades into the view.
none: It appears the model without any animation.
hardwareAccelerated It controls whether to force hardware acceleration for the underlying window.
onDismiss This prop passes a function that will be called once the modal has been dismissed.
onOrientationChange This props is called when the orientation changes while the modal is being displayed. The type of orientation is "portrait" or "landscape".
presentationStyle It controls the appearance of a model (fullScreen, pageSheet, fromSheet, overFullScreen) generally on the large devices.
animated This prop is deprecated. Use the animatedType prop instead, which is discussed above.

React Native Modal Example

Let's see an example of displaying a pop-up modal on clicking the button. Once we clicked the button, state variable isVisible sets to true and opens the Modal component.

To implement the Modal component import Modal from the react-native library.

App.js

Output:

React Native Modal React Native Modal




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA