react-modal

WebJar for react-modal

License

License

MIT
Categories

Categories

React User Interface Web Frameworks
GroupId

GroupId

org.webjars.bower
ArtifactId

ArtifactId

react-modal
Last Version

Last Version

1.4.0
Release Date

Release Date

Type

Type

jar
Description

Description

react-modal
WebJar for react-modal
Project URL

Project URL

http://webjars.org

Download react-modal

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.bower/react-modal/ -->
<dependency>
    <groupId>org.webjars.bower</groupId>
    <artifactId>react-modal</artifactId>
    <version>1.4.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bower/react-modal/
implementation 'org.webjars.bower:react-modal:1.4.0'
// https://jarcasting.com/artifacts/org.webjars.bower/react-modal/
implementation ("org.webjars.bower:react-modal:1.4.0")
'org.webjars.bower:react-modal:jar:1.4.0'
<dependency org="org.webjars.bower" name="react-modal" rev="1.4.0">
  <artifact name="react-modal" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bower', module='react-modal', version='1.4.0')
)
libraryDependencies += "org.webjars.bower" % "react-modal" % "1.4.0"
[org.webjars.bower/react-modal "1.4.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

react-modal

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

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 (http://reactcommunity.org/react-modal/accessibility/)
Modal.setAppElement('#yourAppElement')

function App(){
  var 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:

org.webjars.bower

React Community

React website and its localizations

Versions

Version
1.4.0
1.2.1
1.2.0