Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/akmamun/react-modal-overlay

Accessible simple modal component package for React JS
https://github.com/akmamun/react-modal-overlay

custom-modal modal overlay react react-modal react-modal-component react-modal-popup react-overlay

Last synced: 3 months ago
JSON representation

Accessible simple modal component package for React JS

Awesome Lists containing this project

README

        

# react-modal-overlay

Accessible simple modal overlay component for React JS

[![NPM](https://img.shields.io/npm/v/react-modal-overlay.svg)](https://www.npmjs.com/package/react-modal-overlay) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) [![Build Status](https://travis-ci.org/akmamun/react-modal-overlay.svg?branch=master)](https://travis-ci.org/akmamun/react-modal-overlay)

## Table of Contents

- [Installation](#installation)
- [Usage](#usage)
- [Demos](#demos)

## Installation

To install, you can use [npm](https://npmjs.com/) or [yarn](https://yarnpkg.com):

```bash
npm install react-modal-overlay
yarn add react-modal-overlay
```

## Usage

- Using Hooks

```jsx
import React, { useState } from 'react'
import { Modal } from 'react-modal-overlay'
import 'react-modal-overlay/dist/index.css'

export default function App() {
const [isOpen, setIsOpen] = useState(false)

return (


setIsOpen(true)}>Click Modal!
setIsOpen(false)}>

here is hook modal data




)
}
```

- Class Based Component

```jsx
import React, { Component } from 'react'
import { Modal } from 'react-modal-overlay'
import 'react-modal-overlay/dist/index.css'

export default class ExampleModal extends Component {
state = {
showModal: false
}

toggleModal = () => {
this.setState({
showModal: !this.state.showModal
})
}

render() {
return (


Click Modal!

here is modal data




)
}
}
```

## Demos

- [Hooks example](https://codesandbox.io/s/react-modal-overlay-wybon?file=/src/Hooks.js)

- [Class based Component example](https://codesandbox.io/s/react-modal-overlay-wybon)

## License

MIT © [akmamun](https://github.com/akmamun)