# react-modal Accessible modal dialog component for React.JS [](https://travis-ci.org/reactjs/react-modal) [](https://coveralls.io/github/reactjs/react-modal?branch=master)  [](https://gitter.im/react-modal/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ## Table of Contents * [Installation](#installation) * [API documentation](#api-documentation) * [Examples](#examples) * [Demos](#demos) ## Installation To install, you can use [npm](https://npmjs.org/) or [yarn](https://yarnpkg.com): $ npm install react-modal $ yarn add react-modal ## API documentation The primary documentation for react-modal is the [reference book](https://reactjs.github.io/react-modal), which describes the API and gives examples of its usage. ## Examples 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: ```jsx 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 (http://reactcommunity.org/react-modal/accessibility/) Modal.setAppElement('#yourAppElement') class App extends React.Component { constructor() { super(); this.state = { modalIsOpen: false }; this.openModal = this.openModal.bind(this); this.afterOpenModal = this.afterOpenModal.bind(this); this.closeModal = this.closeModal.bind(this); } openModal() { this.setState({modalIsOpen: true}); } afterOpenModal() { // references are now sync'd and can be accessed. this.subtitle.style.color = '#f00'; } closeModal() { this.setState({modalIsOpen: false}); } render() { return (