Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

react-modal

> 前端框架
Open source

Accessible modal dialog component for React

7.4K stars0 likes2 views
WebsiteGitHub

About

Accessible modal dialog component for React

react-modal

Accessible modal dialog component for React.JS

Table of Contents

  • Installation
  • API documentation
  • Examples
  • Demos

Installation

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):

       <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.

API documentation

The primary documentation for react-modal is the reference book, 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:

…

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.

Demos

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

  • Minimal example
  • Using setAppElement
  • Using onRequestClose
  • Using shouldCloseOnOverlayClick
  • Using inline styles
  • Using CSS classes for styling
  • Customizing the default styles

Issues· 212 open

View all issuesOpen on GitHub
  • #808

    Cannot register modal instance that's already open

    bugreacthardcoreUpdated Jul 16, 2026
  • #1067

    Input composition is canceled with ESC, but modal closes unexpectedly during IME composition

    Updated Jun 27, 2026
  • #960

    'ReactModal' cannot be used as a JSX component.

    not a bugreactversionstypes definitionsUpdated Apr 20, 2026
  • #1056

    dragging property of ant draggable modal not woking when left is applied

    Updated Apr 17, 2026
  • #117

    Prevent scroll to top upon opening

    bugUpdated Jan 5, 2026
  • #954

    Pressing enter key to close button closes the modal but the event is attached to opener element and reopens the modal

    help wanteddiscussionneeds infoeventsmaybe bugUpdated Oct 17, 2025
  • #1062

    iOS 26 - Overlay not full screen

    Updated Oct 15, 2025
  • #1059

    Is it possibly render modal content in dom straightaway?

    Updated Jul 11, 2025
  • #359

    aria-hidden=true on body breaks Accessibility <body class="ReactModal__Body--open" aria-hidden="true">

    enhancementUpdated Jul 8, 2025
  • #1019

    Add support for React & Node 18 (as easy as adding startTransition() on each setState)

    easygood first issueUpdated Jun 25, 2025

> Tags

JavaScriptjavascriptmodalreact

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 2, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架