All Projects → reactjs → React Modal

reactjs / React Modal

Licence: mit
Accessible modal dialog component for React

Programming Languages

javascript
184084 projects - #8 most used programming language
Makefile
30231 projects
python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to React Modal

Gijgo
Gijgo - Free Javascript Controls
Stars: ✭ 424 (-93.69%)
Mutual labels:  modal
Bootstrap Modal
Extends the default Bootstrap Modal class. Responsive, stackable, ajax and more.
Stars: ✭ 5,039 (-24.97%)
Mutual labels:  modal
Splarkcontroller
Custom transition between controllers. Settings controller for your iOS app.
Stars: ✭ 693 (-89.68%)
Mutual labels:  modal
Cleanymodal
Swift UI Kit to present clean modal/alert
Stars: ✭ 437 (-93.49%)
Mutual labels:  modal
Jquery Popup Overlay
jQuery plugin for responsive and accessible modal windows and tooltips
Stars: ✭ 511 (-92.39%)
Mutual labels:  modal
Rmodal.js
A simple 1.2 KB modal dialog with no dependencies
Stars: ✭ 613 (-90.87%)
Mutual labels:  modal
Lightcase
The smart and flexible Lightbox Plugin.
Stars: ✭ 413 (-93.85%)
Mutual labels:  modal
Simplelightbox
Touch-friendly image lightbox for mobile and desktop
Stars: ✭ 744 (-88.92%)
Mutual labels:  modal
Sweetalert
A beautiful replacement for JavaScript's "alert"
Stars: ✭ 21,871 (+225.66%)
Mutual labels:  modal
Ngx Modialog
Modal / Dialog for Angular
Stars: ✭ 691 (-89.71%)
Mutual labels:  modal
React Native Modal
An enhanced, animated, customizable Modal for React Native.
Stars: ✭ 4,671 (-30.45%)
Mutual labels:  modal
Ngx Sweetalert2
Declarative, reactive, and template-driven SweetAlert2 integration for Angular
Stars: ✭ 503 (-92.51%)
Mutual labels:  modal
Mediumlightbox
Nice and elegant way to add zooming functionality for images, inspired by medium.com
Stars: ✭ 671 (-90.01%)
Mutual labels:  modal
React Responsive Modal
Simple responsive react modal
Stars: ✭ 429 (-93.61%)
Mutual labels:  modal
React Useportal
🌀 React hook for Portals
Stars: ✭ 698 (-89.61%)
Mutual labels:  modal
Ngx Gallery
Angular Gallery, Carousel and Lightbox
Stars: ✭ 417 (-93.79%)
Mutual labels:  modal
Css Components
☕️ A set of common UI Components using the power of CSS and without Javascript.
Stars: ✭ 592 (-91.19%)
Mutual labels:  modal
Rodal
A React modal with animations.
Stars: ✭ 754 (-88.77%)
Mutual labels:  modal
Django Admin Interface
django's default admin interface made customizable. popup windows replaced by modals. :mage: ⚡️
Stars: ✭ 717 (-89.32%)
Mutual labels:  modal
Sweet Modal Vue
The sweetest library to happen to modals.
Stars: ✭ 682 (-89.85%)
Mutual labels:  modal

react-modal

NOTE

Need feedback to push a new version of react-modal forward. See issue #881.

Accessible modal dialog component for React.JS

Build Status Coverage Status gzip size Join the chat at https://gitter.im/react-modal/Lobby

Table of Contents

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:

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 (https://reactcommunity.org/react-modal/accessibility/)
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.
    subtitle.style.color = '#f00';
  }

  function closeModal() {
    setIsOpen(false);
  }

  return (
    <div>
      <button onClick={openModal}>Open Modal</button>
      <Modal
        isOpen={modalIsOpen}
        onAfterOpen={afterOpenModal}
        onRequestClose={closeModal}
        style={customStyles}
        contentLabel="Example Modal"
      >
        <h2 ref={(_subtitle) => (subtitle = _subtitle)}>Hello</h2>
        <button onClick={closeModal}>close</button>
        <div>I am a modal</div>
        <form>
          <input />
          <button>tab navigation</button>
          <button>stays</button>
          <button>inside</button>
          <button>the modal</button>
        </form>
      </Modal>
    </div>
  );
}

ReactDOM.render(<App />, appElement);

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:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].