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>
| ConfirmOptions | Type | Description |
|---|---|---|
| title | string? | title |
| message | string | body (required) |
| confirmText | string? | confirm button label |
| cancelText | string? | cancel button label |
| danger | boolean? | destructive action (danger confirm button) |
Behavior & boundaries:
- Resolves
trueon confirm /falseon cancel - One confirm at a time: a new confirm settles the pending one with
false— no dangling promises - Resolves
falseimmediately under SSR (module state never leaks across requests)