Alert

Use alerts when you want to display a message to the user, but you don't want to give them any choice to proceed.

UseBootstrapDialog.alert('Welcome to our website! We are glad to have you here.')
UseBootstrapDialog.alert({
  html: '<b>Welcome to our website!</b> We are glad to have you here.',
})
UseBootstrapDialog.alert({
  text: 'Welcome! Enjoy your time on our site.',
  modalDialogClassName: 'modal-sm',
})
UseBootstrapDialog.alert({
  text: 'Welcome! Enjoy your time on our site. Let us know if you need anything.',
  modalDialogClassName: 'modal-lg',
})
UseBootstrapDialog.alert({
  text: 'Welcome to our website! We are glad to have you here. Enjoy your stay and feel free to explore our content.',
  modalDialogClassName: 'modal-xl',
})
UseBootstrapDialog.alert({
  modalDialogClassName: 'modal-fullscreen',
  html: '<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p><p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p><p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>',
})
UseBootstrapDialog.alert({
  html: '<b>Welcome to our website!</b> We are glad to have you here. <button type="button" class="btn btn-sm btn-success" data-bs-dismiss="modal">Awesome</button>',
  closeBtn: false,
})
UseBootstrapDialog.alert({
  staticBackdrop: true,
  text: 'I will not close if you click outside of me. Don not even try to press escape key.',
})
const instance = UseBootstrapDialog.alert({
  staticBackdrop: true,
  closeBtn: false,
  text: 'I will close programmatically in 3 seconds.',
})

setTimeout(() => {
  if (instance) {
    instance.hide()
  }
}, 3000)

Confirm

Use confirms when you want to present a yes-or-no option to the user.

UseBootstrapDialog.confirm({
  callback(confirmed) {
    alert(`confirmed: ${confirmed}`)
  },
})
UseBootstrapDialog.confirm({
  title: {
    html: '<h6>Deactivate account</h6>',
  },
  html: 'Are you sure you want to deactivate your account? All of your data will be <b>permanently</b> removed. This action cannot be undone.',
  footer: {
    okBtn: {
      text: 'Deactivate',
      className: 'btn-danger',
    },
  },
  async callback(confirmed) {
    if (confirmed) {
      const loading = UseBootstrapDialog.alert({
        html: `<div class="spinner-border spinner-border-sm me-2" role="status"></div>Please wait...`,
        closeBtn: false,
        staticBackdrop: true,
      })

      // your processing code..
      // await ...

      if (loading) {
        loading.hide()
        loading.modal.addEventListener('hidden.bs.modal', () => {
          UseBootstrapDialog.alert({
            html: `
              <div class="d-flex gap-2">
                <svg class="text-success" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>
                Account deactivated.
              </div>
              `,
          })
        })
      }
    }
  },
})

Prompt

The prompt method displays a dialog box that prompts the user for input.

UseBootstrapDialog.prompt({
  text: 'Please enter your name',
  callback(value) {
    alert(`Hello ${value}`)
  },
})
UseBootstrapDialog.prompt({
  html: 'Please enter your name, this is <span class="text-danger">required</span> and cannot be empty.',
  required: true,
  closeBtn: false,
  defaultValue: 'John',
  callback(value) {
    alert(`Hello ${value}`)
  },
  footer: {
    okBtn: {
      html: `
      <div class="d-flex gap-2">
        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2"/><path d="M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2"/><path d="M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8"/><path d="M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15"/></svg>
        Hello
      </div>`,
      className: 'btn-success',
    },
  },
})