# react-standard-modal

> A clean & simple modal component for React

Latest version **0.1.12** (published 2020-12-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-standard-modal
pnpm add react-standard-modal
yarn add react-standard-modal
bun add react-standard-modal
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.12 |
| Published | 2020-12-30 |
| First published | 2020-11-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 588.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Darshana Gunawardana |
| Maintainers | darshgun |
| Keywords | modal, react |

## Links

- npm: https://www.npmjs.com/package/react-standard-modal
- Repository: https://github.com/darshgun/react-standard-modal
- npm.io page: https://npm.io/package/react-standard-modal

## Dependencies (2)

- [classnames](https://npm.io/package/classnames.md) ^2.2.6
- [prop-types](https://npm.io/package/prop-types.md) ^15.7.2

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.1.12 (latest) — 2020-12-30
- 0.1.10 — 2020-11-28
- 0.1.6 — 2020-11-24
- 0.1.5 — 2020-11-24
- 0.1.4 — 2020-11-23
- 0.1.3 — 2020-11-23
- 0.1.2 — 2020-11-23
- 0.1.1 — 2020-11-23
- 0.1.0 — 2020-11-22

## README

# react-standard-modal

A clean & simple modal component for React.

![npm](https://img.shields.io/npm/v/react-standard-modal) ![npm](https://img.shields.io/npm/dt/react-standard-modal) ![npm bundle size](https://img.shields.io/bundlephobia/min/react-standard-modal) ![GitHub](https://img.shields.io/github/license/darshgun/react-standard-modal) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](http://makeapullrequest.com)

## Table of Contents

- [Demos](#demos)
- [Installation](#installation)
- [Basic usage](#basic-usage)
- [API documentation](#api-documentation)
- [License](#license)
- [Contributors](#contribute)

## Demos

- [Basic example](https://codesandbox.io/s/react-standard-modal-basic-example-4brrf)
- [Storybook example](https://codesandbox.io/s/react-standard-modal-storybook-s2mhq)

## Installation

To install use [yarn](https://yarnpkg.com),

    $ yarn add react-standard-modal

or [npm](https://npmjs.org/),

    $ npm install --save react-standard-modal

## Basic usage

```js
import React, { Fragment, useState } from 'react';
import Modal from 'react-standard-modal';

function App() {
  const [isOpen, setIsOpen] = useState(false);
  const handleClose = () => {
    setIsOpen(false);
  };

  return (
    <Fragment>
      <Button onClick={() => setIsOpen(true)}>Open modal</Button>
      <Modal open={isOpen} onClose={handleClose}>
        {body}
      </Modal>
    </Fragment>
  );
}
```

## API documentation

| Prop                    | Type                                                 | Required | Description                                                                                 |
| ----------------------- | ---------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------- |
| **children**            | node                                                 |          | Provide the contents of your Modal                                                          |
| **className**           | `{ Modal: string, Overlay: string, Portal: string }` |          | Class names for Modal, Portal and Overlay components                                        |
| **closeOnOverlayClick** | boolean                                              |          | Todo: Closes the modal when clicking on Overlay.                                            |
| **disableOverlayClick** | boolean                                              |          | Disables Overlay click                                                                      |
| **disableOverlay**      | boolean                                              |          | Specify whether Overlay should render or not. If `true`, Overlay component will not render. |
| **disablePortal**       | boolean                                              |          | If `true`, Modal & Overlay will mount inside the parent component.                          |
| **onClose**             | function                                             | ✓        | Specify the function that fires on Modal closes.                                            |
| **onOpen**              | function                                             |          | Specify the function that fires on Modal opens.                                             |
| **open**                | boolean                                              | ✓        | Specify whether the Modal is currently open.                                                |
| **overlayClick**        | function                                             |          | Specify the function that fires when clicking on Overlay.                                   |
| **overlayRef**          | function                                             |          | Ref callback of the Overlay component.                                                      |
| **style**               | `{ Modal: object, Overlay: object, Portal: object }` |          | Inline styles for Modal, Portal and Overlay components.                                     |
| **unMountIfClosed**     | boolean                                              |          | If `true`, the modal will not mount to DOM when it's not open.                              |

## License

[MIT](https://github.com/darshgun/react-standard-modal/blob/master/LICENSE)

## Contribute

Contributions of any kind welcome!

---
_Source: https://npm.io/package/react-standard-modal · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
