General Options
Title¶
The title of the popup, as HTML.
TitleText¶
The title of the popup, as text. Useful to avoid HTML injection.
Html¶
A HTML description for the popup.
If text
and html
parameters are provided in the same time, html will be used.
Text¶
A description for the popup. If text
and html
parameters are provided in the same time, html
will be used.
Icon¶
The icon of the popup. SweetAlert2 comes with 5 built-in icon which will show a corresponding icon animation.
IconColor¶
Use this to change the color of the icon.
IconHtml¶
The custom HTML content for an icon.
Animation¶
If set to false
, the popup animation will be disabled. Default true
ShowClass¶
CSS classes for animations when showing a popup (fade in).
HideClass¶
CSS classes for animations when hiding a popup (fade out).
Footer¶
The footer of the popup. Can be either plain text or HTML.
Backdrop¶
Whether or not SweetAlert2 should show a full screen click-to-dismiss backdrop. Default true
boolean
or a string
which will be assigned to the CSS background
property.
Toast¶
Whether or not an alert should be treated as a toast notification.
This option is normally coupled with the position
parameter and a timer. Toasts are NEVER autofocused.
Default false
Target¶
The container element for adding popup into. Default 'body'
Input¶
Width¶
Popup window width, including paddings (box-sizing: border-box). Can be in any CSS unit (px
, em/rem
, %
).
Default '32em'
Padding¶
Popup window padding. Can be in any CSS unit (px
, em/rem
, %
). Default '0 0 1.25em'
Color¶
Color for title, content and footer (CSS color
property). The default color is '#545454'
.
Background¶
Popup window background (CSS background property). The default background is '#fff'
.
Position¶
Popup window position. Default 'center'
Grow¶
Paired with window position, sets the direction the popup should grow in, can be set to false
.
'row'
, 'column'
, 'fullscreen'
.
Timer¶
Auto close timer of the popup. Set in ms (milliseconds).
TimerProgressBar¶
If set to true
, the timer will have a progress bar at the bottom of a popup. Mostly, this feature is useful with toasts. Default false
HeightAuto¶
By default, SweetAlert2 sets html's and body's CSS height
to auto !important
.
If this behavior isn't compatible with your project's layout, set heightAuto
to false
.
Default true
AllowOutsideClick¶
If set to false
, the user can't dismiss the popup by clicking outside it.
You can also pass a custom function returning a boolean value, e.g. if you want to disable outside clicks for the loading state of a popup.
Default true
AllowEscapeKey¶
If set to false
, the user can't dismiss the popup by pressing the Esc key. You can also pass a custom function returning a boolean value,
e.g. if you want to disable the Esc key for the loading state of a popup. Default true
StopKeydownPropagation¶
If set to false
, SweetAlert2 will allow keydown
events propagation to the document. Default true
KeydownListenerCapture¶
Useful for those who are using SweetAlert2 along with Bootstrap modals.
By default keydownListenerCapture
is false
which means when a user hits Esc, both SweetAlert2 and Bootstrap modals will be closed.
Set keydownListenerCapture
to true
to fix that behavior. Default false
LoaderHtml¶
Use this to change the HTML content of the loader.
ShowLoaderOnConfirm¶
Set to true
to disable buttons and show the loader instead of the Confirm button. Use it in combination with the preConfirm
parameter. Default false
ShowLoaderOnDeny¶
Set to true
to disable buttons and show the loader instead of the Deny button. Use it in combination with the preDeny
parameter. Default false
ReturnInputValueOnDeny¶
If you want to return the input value as result.value
when denying the popup, set to true
.
Otherwise, the denying will set result.value
to false
. Default false
ImageUrl¶
Add a customized icon for the popup. Should contain a string with the path or URL to the image.
ImageWidth¶
If imageUrl is set, you can specify imageWidth to describes image width. Can be in any CSS unit (px
, em/rem
, %
).
ImageHeight¶
Custom image height. Can be in any CSS unit (px
, em/rem
, %
).
ImageAlt¶
An alternative text for the custom image icon.
InputLabel¶
InputPlaceholder¶
InputValue¶
Input field initial value.
If the input type is select
, inputValue
will represent the selected <option>
tag.
If the input type is checkbox
, inputValue
will represent the checked
state.
If the input type is email
, number
, tel
, text
, email
, number
, tel
or textarea
, a Promise can be accepted as inputValue
.
InputOptions¶
If input
parameter is set to select
or radio
, you can provide options.
Can be a Map or a plain object, with keys that represent option values and values that represent option text.
You can also provide plain object or Map as values that will represented a group of options, being the label of this <optgroup>
the key.
Finally, you can also provide a Promise that resolves with one of those types.
InputAutoFocus¶
Automatically focus the input when popup is shown. Set this parameter to false
to disable auto-focusing. Default true
InputAutoTrim¶
Automatically remove whitespaces from both ends of a result string. Set this parameter to false
to disable auto-trimming. Default true
InputAttributes¶
HTML input attributes (e.g. min
, max
, autocomplete
, accept
), that are added to the input field.
Object keys will represent attributes names, object values will represent attributes values.
.InputAttributes(ia => ia
.Add("maxlength", "10")
.Add("autocapitalize", "off")
.Add("autocorrect", "off"))
ValidationMessage¶
A custom validation message for default validators (email
, url
).
ProgressSteps¶
Progress steps, useful for queues.
CurrentProgressStep¶
ProgressStepsDistance¶
Distance between progress steps. Can be in any CSS unit (px
, em/rem
, %
).