Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

sweetalert2-react-content

> 前端框架
Open source

Official SweetAlert2 enhancer adding support for React elements as content

730 stars0 likes3 views
WebsiteGitHub

About

Official SweetAlert2 enhancer adding support for React elements as content

sweetalert2-react-content

Official SweetAlert2 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

javascript
import Swal from 'sweetalert2'
import withReactContent from 'sweetalert2-react-content'

const MySwal = withReactContent(Swal)

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

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

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScriptreactsweetalertsweetalert2

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架