Skip to content
nexus-dialogs
GitHub npm

SweetAlert2 compatibility

What part of SweetAlert2 nexus-dialogs/swal covers and what it doesn't. Compatibility is not absolute and is not meant to be: it is a door to migrate gradually toward the library's own API. This table is verified on every change (test/unit/swal-matriz.test.ts): if the adapter recognizes a parameter that is not here, or a "compatible" one has no test, CI fails. The status column in this English page uses the Spanish page's table as its source: if they differ, the Spanish one is authoritative.

#What each status means

StatusMeaning
compatibleDoes the same as in SweetAlert2 and has a test.
partialWorks with a limitation or a difference (see the note).
ignoredAccepted so your code doesn't fail, but has no effect: the look is decided by the button standard and the theme.
unsupportedAccepted and does nothing because it has no equivalent.

#Parameters

ParameterStatusNote
titlecompatible
titleTextcompatible
textcompatible
htmlpartialShown as text by default (strictHtml); with your own content, configure({ strictHtml: false }) (without a bundler, Swal.configure(…)).
iconcompatible
footerpartialShown as plain text: tags are removed.
toastpartialUses the nexus-dialogs/toast queue; it doesn't accept all of a dialog's parameters.
positionpartialOnly for toasts, and it changes the position of all toasts (there is a single queue).
widthpartialOnly numbers and px; with other units the standard width is used.
timercompatible
timerProgressBarcompatible
showConfirmButtoncompatible
showDenyButtoncompatible
showCancelButtoncompatible
showCloseButtoncompatible
confirmButtonTextcompatible
denyButtonTextcompatible
cancelButtonTextcompatible
focusCancelcompatible
focusDenycompatible
allowOutsideClickcompatible
allowEscapeKeycompatible
inputcompatible
inputLabelcompatible
inputPlaceholdercompatible
inputValuecompatible
inputOptionscompatible
inputAttributescompatible
inputValidatorcompatible
validationMessagecompatible
preConfirmcompatible
preDenycompatible
willOpencompatible
didOpencompatible
didRendercompatible
willClosecompatible
didClosecompatible
didDestroycompatible
iconHtmlpartialGoes through sanitize / strictHtml like html.
imageUrlcompatible
imageWidthcompatible
imageHeightcompatible
imageAltcompatible
progressStepscompatible
currentProgressStepcompatible
progressStepsDistancecompatible
closeButtonHtmlpartialGoes through sanitize / strictHtml like html.
closeButtonAriaLabelcompatible
confirmButtonAriaLabelcompatible
denyButtonAriaLabelcompatible
cancelButtonAriaLabelcompatible
reverseButtonscompatible
allowEnterKeycompatible
inputAutoFocuscompatible
inputAutoTrimcompatible
returnInputValueOnDenycompatible
targetpartialMounts the dialog in that element, but it is still modal and in the top layer.
themepartialUnderstands light, dark and auto; the library's themes are chosen with configure({ theme }).
templatepartialReads <swal-title>, <swal-html>, <swal-icon>, <swal-image>, <swal-input>, <swal-button>, <swal-footer> and <swal-param>; it doesn't accept <swal-function-param>.
draggablecompatible
confirmButtonColorignoredColors come from the button standard and the theme.
denyButtonColorignoredSame as confirmButtonColor.
cancelButtonColorignoredSame as confirmButtonColor.
buttonsStylingignoredButtons always carry the standard style.
customClassignoredThe content lives in a Shadow DOM: your CSS classes don't reach it. Use themes.
backgroundignoredUse configure({ theme }).
colorignoredUse configure({ theme }).
paddingignoredSpacing is the theme's.
iconColorignoredThe icon color depends on the type.
backdropignoredThe backdrop is always the browser's (modal <dialog>).
growignoredSizes are size or width.
animationunsupportedMotion comes from the theme and respects "reduce motion".
showClassunsupportedSame as animation.
hideClassunsupportedSame as animation.
heightAutoignoredNot needed: the dialog doesn't alter the page height.
scrollbarPaddingignoredThe library compensates for the scrollbar by itself.
topLayerunsupportedIt is always in the browser's top layer.
stopKeydownPropagationignoredKeyboard propagation is not stopped.
keydownListenerCaptureignoredKeyboard events are not captured in the capture phase.
showLoaderOnConfirmignoredWith an async preConfirm the "processing" indicator is always shown.
showLoaderOnDenyignoredWith an async preDeny the "processing" indicator is always shown.
focusConfirmignoredThe initial focus is decided by the library (on destructive actions, Cancel).
returnFocusignoredOn closing, focus always returns to the element that opened the dialog.
loaderHtmlpartialGoes through sanitize / strictHtml like html.

#Methods and accessors

Compatible: Swal.fire, mixin, close, update, isVisible, showLoading, hideLoading, isLoading, getLoader, showValidationMessage, resetValidationMessage, enableButtons, disableButtons, enableInput, disableInput, clickConfirm, clickDeny, clickCancel, the accessors (getPopup, getContainer, getTitle, getHtmlContainer, getIcon, getImage, getInput, getActions, getFooter, getCloseButton, getTimerProgressBar, getProgressSteps, getFocusableElements…), the timers (stopTimer, resumeTimer, toggleTimer, increaseTimer, getTimerLeft, isTimerRunning), argsToParams, isValidParameter, isUpdatableParameter, bindClickHandler and DismissReason.

No equivalent: Swal.version.

#Intentional differences

Migration guide with runnable examples: Migrate from SweetAlert2.