Doko's new lair
React Native Sweet Alert

API Reference

Full API surface for react-native-sweet-alert.

SweetAlert.showAlert(options)

Shows a native alert dialog. Returns a promise that resolves to { confirmed: boolean } once the user dismisses it - confirmed reflects which button was pressed (or false if dismissed via cancellable tap-outside).

const result = await SweetAlert.showAlert({
  style: 'success',
  title: 'Great job!',
  subTitle: 'Everything went smoothly.',
  confirmButtonTitle: 'OK',
});

Options

OptionTypeNotes
stylestringRequired. success/error/warning/normal/progress
titlestring
subTitlestring
confirmButtonTitlestring
confirmButtonColorstringHex color, e.g. #4A90D9
otherButtonTitlestringOmit to show a single-button alert
otherButtonColorstringHex color
cancellablebooleanTap outside to dismiss
progressnumber0-100; progress style only. Omit for indeterminate
progressBarColorstringprogress style only
progressCircleRadiusnumberprogress style only, in dp/pt
progressBarWidthnumberprogress style only, in dp/pt
progressRimWidthnumberprogress style only, in dp/pt (Android)
progressSpinSpeednumberprogress style only (Android)

SweetAlert.setProgress(value)

Updates the progress value (0-100) of the currently displayed progress-style alert.

SweetAlert.setProgress(50);

SweetAlert.dismissAlert()

Programmatically dismisses the currently displayed alert.

SweetAlert.dismissAlert();

On this page