Accessible modal dialog component for React
Accessible modal dialog component for React.JS
To install, you can use npm or yarn:
$ npm install --save react-modal
$ yarn add react-modalTo 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):
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-modal/3.14.3/react-modal.min.js"
integrity="sha512-MY2jfK3DBnVzdS2V8MXo5lRtr0mNRroUI9hoLVv2/yL3vrJTam3VzASuKQ96fLEpyYIT4a8o7YgtUs5lPjiLVQ=="
crossorigin="anonymous"
referrerpolicy="no-referrer"></script>
Use <ReactModal> tag inside your React CDN app.
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:
…You can find more examples in the examples directory, which you can run in a
local development server using npm start or yarn run start.
There are several demos hosted on CodePen which demonstrate various features of react-modal:
Cannot register modal instance that's already open
Input composition is canceled with ESC, but modal closes unexpectedly during IME composition
'ReactModal' cannot be used as a JSX component.
dragging property of ant draggable modal not woking when left is applied
Prevent scroll to top upon opening
Pressing enter key to close button closes the modal but the event is attached to opener element and reopens the modal
iOS 26 - Overlay not full screen
Is it possibly render modal content in dom straightaway?
aria-hidden=true on body breaks Accessibility <body class="ReactModal__Body--open" aria-hidden="true">
Add support for React & Node 18 (as easy as adding startTransition() on each setState)