Skip to content

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:

FieldTypeDefaultDescription
titlestringtitle
messagestringbody (required)
confirmTextstring'确定'confirm button label
cancelTextstring'取消'cancel button label
dangerbooleanfalsedestructive action (danger confirm button)
  • Resolves true (confirmed) / false (cancelled)
  • A new confirm settles any pending one with false — no dangling promises
  • Resolves false immediately under SSR

Full mechanics: useConfirm.