# sweetalert2-react-content

> Official sweetalert2 enhancer adding support for React elements as content.

Latest version **5.1.2** (published 2026-03-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install sweetalert2-react-content
pnpm add sweetalert2-react-content
yarn add sweetalert2-react-content
bun add sweetalert2-react-content
```

## Health

**Score 65/100 (B)** — status: stable.

Positive: has types; esm support; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.1.2 |
| Published | 2026-03-15 |
| First published | 2018-02-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 70.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 728 |
| Author | Matthew Francis Brunetti |
| Maintainers | limonte |
| Keywords | sweetalert, sweetalert2, react, content |

## Links

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

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

- 5.1.2 (latest) — 2026-03-15
- 5.1.1 — 2025-12-13
- 5.1.0 — 2024-12-16
- 5.0.7 — 2022-10-27
- 5.0.6 — 2022-10-27
- 5.0.5 — 2022-10-19
- 5.0.4 — 2022-10-19
- 5.0.3 — 2022-08-17
- 5.0.2 — 2022-07-22
- 5.0.1 — 2022-06-28
- 5.0.0 — 2022-04-12
- 4.2.0 — 2021-10-18
- 4.1.1 — 2021-07-22
- 4.1.0 — 2021-06-20
- 4.0.1 — 2021-05-19
- … 41 more at https://npm.io/package/sweetalert2-react-content/versions

## README

# sweetalert2-react-content

Official [SweetAlert2](https://sweetalert2.github.io/) enhancer adding support for React elements as content.

- Simple example: https://sweetalert2.github.io/recipe-gallery/sweetalert2-react.html
- With React Router: https://sweetalert2.github.io/recipe-gallery/sweetalert2-react-router.html
- With react-day-picker: https://sweetalert2.github.io/recipe-gallery/input-datepicker.html

---

The following options can be React elements:

- `title`
- `html`
- `confirmButtonText`
- `denyButtonText`
- `cancelButtonText`
- `footer`
- `closeButtonHtml`
- `iconHtml`
- `loaderHtml`

## Installation

```bash
npm install sweetalert2 sweetalert2-react-content
```

## Usage Example

```jsx
import Swal from 'sweetalert2'
import withReactContent from 'sweetalert2-react-content'

const MySwal = withReactContent(Swal)

MySwal.fire({
  title: <p>Hello World</p>,
  didOpen: () => {
    // `MySwal` is a subclass of `Swal` with all the same instance & static methods
    MySwal.showLoading()
  },
}).then(() => {
  return MySwal.fire(<p>Shorthand works too</p>)
})
```

The `dist/sweetalert2-react-content.umd.js` file defines `window.sweetalert2ReactContent` in non-CJS/AMD environments.

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