Official SweetAlert2 enhancer adding support for React elements as content
Official SweetAlert2 enhancer adding support for React elements as content
Official SweetAlert2 enhancer adding support for React elements as content.
The following options can be React elements:
titlehtmlconfirmButtonTextdenyButtonTextcancelButtonTextfootercloseButtonHtmliconHtmlloaderHtmlnpm install sweetalert2 sweetalert2-react-contentimport 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.
No open issues yet, or sync has not completed.