# react-inline-modal

> Use React modals directly in your handlers

Latest version **1.1.5** (published 2024-08-03) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.5 |
| Published | 2024-08-03 |
| First published | 2024-07-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Mark Yaraskavitch |
| Maintainers | myarask |
| Keywords | react, modal, inline, promise, async, DX, developer experience |

## Links

- npm: https://www.npmjs.com/package/react-inline-modal
- Repository: https://github.com/myarask/react-inline-modal
- Homepage: https://github.com/myarask/react-inline-modal#readme
- Issues: https://github.com/myarask/react-inline-modal/issues
- npm.io page: https://npm.io/package/react-inline-modal

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

- 1.1.5 (latest) — 2024-08-03
- 1.1.4 — 2024-08-03
- 1.1.3 — 2024-08-03
- 1.1.2 — 2024-08-03
- 1.1.1 — 2024-08-01
- 1.1.0 — 2024-07-31
- 1.0.2 — 2024-07-29
- 1.0.1 — 2024-07-29
- 1.0.0 — 2024-07-29

## README

# React Inline Modal

Use React modals directly in your handlers to align with the user's experience.

```ts
const handleClick = async () => {
  // Collect user input asynchronously
  // (ConfirmationModal is a React component)
  const confirmation = await modal.show(ConfirmationModal, {
    // Pass props to the modal
    message: "Are you sure?",
  });

  // Handle logical branches
  if (!confirmation) return;

  // Continue with the happy path
  alert("Proceeding...");
};
```

## Quick Start

Add the `InlineModalProvider` to your app:

```tsx
import { InlineModalProvider } from "react-inline-modal";

const App = () => {
  return (
    <InlineModalProvider>
      <MyContent />
    </InlineModalProvider>
  );
};
```

Prepare your modal:

```tsx
// Bring your own stylized modal
import { Modal } from "any-component-library";

const ConfirmationModal = ({ resolve, message }) => {
  return (
    <Modal open onClose={() = resolve(false)}>
      <h1>{message}</h1>
      <button onClick={() => resolve(true)}>Yes</button>
      <button onClick={() => resolve(false)}>No</button>
    </Modal>
  );
};
```

Use the modal in a handler:

```tsx
const DeleteButton = () => {
  const modal = useInlineModal();

  const handleClick = async () => {
    const confirmation = await modal.show(ConfirmationModal, {
      message: "Are you sure?",
    });

    if (!confirmation) return;

    alert("Proceeding...");
  };

  return <button onClick={handleClick}>Delete</button>;
};
```

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