/React Native


The Modal component is a simple way to present content above an enclosing view.

Note: If you need more control over how to present modals over the rest of your app, then consider using a top-level Navigator.

import React, { Component } from 'react';
import { Modal, Text, TouchableHighlight, View } from 'react-native';

class ModalExample extends Component {

  state = {
    modalVisible: false,

  setModalVisible(visible) {
    this.setState({modalVisible: visible});

  render() {
    return (
      <View style={{marginTop: 22}}>
          onRequestClose={() => {alert("Modal has been closed.")}}
         <View style={{marginTop: 22}}>
            <Text>Hello World!</Text>

            <TouchableHighlight onPress={() => {
              <Text>Hide Modal</Text>


        <TouchableHighlight onPress={() => {
          <Text>Show Modal</Text>



animated?: bool


Use the animationType prop instead.

animationType?: enum('none', 'slide', 'fade')

The animationType prop controls how the modal animates.

  • slide slides in from the bottom
  • fade fades into view
  • none appears without an animation

Default is set to none.

onShow?: function

The onShow prop allows passing a function that will be called once the modal has been shown.

transparent?: bool

The transparent prop determines whether your modal will fill the entire view. Setting this to true will render the modal over a transparent background.

visible?: bool

The visible prop determines whether your modal is visible.

androidhardwareAccelerated?: bool

The hardwareAccelerated prop controls whether to force hardware acceleration for the underlying window.

androidonRequestClose?: Platform.OS === 'android' ? PropTypes.func.isRequired : PropTypes.func

The onRequestClose callback is called when the user taps the hardware back button.

iosonOrientationChange?: function

The onOrientationChange callback is called when the orientation changes while the modal is being displayed. The orientation provided is only 'portrait' or 'landscape'. This callback is also called on initial render, regardless of the current orientation.

iossupportedOrientations?: [enum('portrait', 'portrait-upside-down', 'landscape', 'landscape-left', 'landscape-right')]

The supportedOrientations prop allows the modal to be rotated to any of the specified orientations. On iOS, the modal is still restricted by what's specified in your app's Info.plist's UISupportedInterfaceOrientations field.

© 2015–2017 Facebook Inc.
Licensed under the Creative Commons Attribution 4.0 International Public License.