Need help with react-modal?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

6.6K Stars 786 Forks MIT License 542 Commits 158 Opened issues


Accessible modal dialog component for React

Services available


Need anything else?

Contributors list



Need feedback to push a new version of

forward. See issue #881.

Accessible modal dialog component for React.JS

Build Status Coverage Status gzip size Join the chat at

Table of Contents


To install, you can use npm or yarn:

$ npm install --save react-modal
$ yarn add react-modal

To install react-modal in React CDN app:

  • Add this CDN script tag after React CDN scripts and before your JS files (for example from cdnjs):

  • Use

     tag inside your React CDN app.

API documentation

The primary documentation for react-modal is the reference book, which describes the API and gives examples of its usage.


Here is a simple example of react-modal being used in an app with some custom styles and focusable input elements within the modal content:

import React from 'react';
import ReactDOM from 'react-dom';
import Modal from 'react-modal';

const customStyles = { content: { top: '50%', left: '50%', right: 'auto', bottom: 'auto', marginRight: '-50%', transform: 'translate(-50%, -50%)', }, };

// Make sure to bind modal to your appElement ( Modal.setAppElement('#yourAppElement');

function App() { let subtitle; const [modalIsOpen, setIsOpen] = React.useState(false);

function openModal() { setIsOpen(true); }

function afterOpenModal() { // references are now sync'd and can be accessed. = '#f00'; }

function closeModal() { setIsOpen(false); }

return (

Open Modal

(subtitle = _subtitle)}>Hello

I am a modal
tab navigation stays inside the modal
); }

ReactDOM.render(, appElement);

You can find more examples in the

directory, which you can run in a local development server using
npm start
yarn run start


There are several demos hosted on CodePen which demonstrate various features of react-modal:

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.