Skip to content

Dialogs ​

useConfirm gives you promise-based confirm() and prompt() — no callbacks, no native browser popups.

ts
import { useConfirm } from 'notifications-kit/vue'
const { confirm, prompt } = useConfirm()

confirm ​

Returns true if the user confirms, false otherwise.

ts
async function deleteItem() {
  const ok = await confirm('Delete this item?', {
    title: 'Are you sure?',
    confirmText: 'Delete',
    cancelText: 'Cancel',
    danger: true,        // styles the confirm button as destructive
  })

  if (ok) {
    // proceed
  }
}

prompt ​

Returns the entered string, or null if cancelled.

ts
const name = await prompt('What should we call you?', {
  placeholder: 'Your name',
  defaultValue: '',
})

if (name !== null) {
  // use name
}

Why promise-based? ​

Native confirm() / prompt() block the main thread, can't be styled, and look out of place. These give you the same simple await flow with your app's design and dark mode applied.

Released under the MIT License.