Confirm
Promise-based confirmation dialog. A "host component + composable" pair: mount LxConfirmHost once at your app root, then await confirm({...}) anywhere.
Mount the host
vue
<!-- App.vue (app root, once) -->
<template>
<RouterView />
<LxConfirmHost />
</template>
<script setup lang="ts">
import { LxConfirmHost } from '@luxeanor/ui'
</script>This docs site already mounts the host in its layout — the demo below just works.
Usage
Pass danger: true for destructive actions (delete/void/remove) — the confirm button switches to the danger variant:
API
useConfirm().confirm(options): Promise<boolean>
ConfirmOptions:
| Field | Type | Default | Description |
|---|---|---|---|
| title | string | — | title |
| message | string | — | body (required) |
| confirmText | string | '确定' | confirm button label |
| cancelText | string | '取消' | cancel button label |
| danger | boolean | false | destructive action (danger confirm button) |
- Resolves
true(confirmed) /false(cancelled) - A new confirm settles any pending one with
false— no dangling promises - Resolves
falseimmediately under SSR
Full mechanics: useConfirm.