Skip to content

useConfirm

Promise-based confirm, paired with a single root-mounted LxConfirmHost (component usage and live demo on the Confirm component page).

Usage

ts
import { useConfirm } from '@luxeanor/ui'

const { confirm } = useConfirm()

const ok = await confirm({
  title: 'Delete project',
  message: 'This cannot be undone. Continue?',
  confirmText: 'Delete',
  danger: true,
})
if (ok) { /* perform deletion */ }

API

confirm(options: ConfirmOptions): Promise<boolean>

ConfirmOptionsTypeDescription
titlestring?title
messagestringbody (required)
confirmTextstring?confirm button label
cancelTextstring?cancel button label
dangerboolean?destructive action (danger confirm button)

Behavior & boundaries:

  • Resolves true on confirm / false on cancel
  • One confirm at a time: a new confirm settles the pending one with false — no dangling promises
  • Resolves false immediately under SSR (module state never leaks across requests)